projection_limit_offset.sim 10.7 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2 3

system sh/deploy.sh -n dnode1 -i 1
H
hjxilinx 已提交
4
system sh/cfg.sh -n dnode1 -c walLevel -v 0
S
slguan 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect

$dbPrefix = group_db
$tbPrefix = group_tb
$mtPrefix = group_mt
$tbNum = 8
$rowNum = 10000
$totalNum = $tbNum * $rowNum

print =============== projection_limit_offset.sim
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i

$tstart = 100000

sql drop database if exits $db -x step1
step1:
S
scripts  
slguan 已提交
25
sql create database if not exists $db maxTables 4 keep 36500
S
slguan 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
sql use $db
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))

$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i
  $tg2 = ' . abc
  $tg2 = $tg2 . '
  sql create table $tb using $mt tags( $i , $tg2 )

  $x = 0
  while $x < $rowNum
    $ms = $x . m
    $c = $x / 100
    $c = $c * 100
    $c = $x - $c

    $binary = ' . binary
    $binary = $binary . $c
    $binary = $binary . '

    $nchar = ' . nchar
    $nchar = $nchar . $c
    $nchar = $nchar . '

    sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
    $tstart = $tstart + 1
    $x = $x + 1
  endw

  $i = $i + 1
  $tstart = 100000
endw

sleep 100

$i1 = 1
$i2 = 0

$db = $dbPrefix . $i
$mt = $mtPrefix . $i

$dbPrefix = group_db
$tbPrefix = group_tb
$mtPrefix = group_mt

$tb1 = $tbPrefix . $i1
$tb2 = $tbPrefix . $i2
$ts1 = $tb1 . .ts
$ts2 = $tb2 . .ts

#===============select * from super_table limit/offset[TBASE-691]=================================
sql select ts from group_mt0
print $rows

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 0;
if $rows != 4008 then
H
Haojun Liao 已提交
83
  print expect 4008, actual:$rows
S
slguan 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
  return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 1;
if $rows != 4007 then
  return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 101;
print $rows
if $rows != 3907 then
  return -1
endi

if $data00 != @70-01-01 08:01:43.101@ then
  return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 902;
if $rows != 3106 then
  return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 400;
if $rows != 3608 then
  return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 4007;
if $rows != 1 then
  return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 2000 offset 4008;
if $rows != 0 then
  return -1
endi

#==================================order by desc, multi vnode, limit/offset===================================
sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 0;
if $rows != 4008 then
  return -1
endi

if $data00 != @70-01-01 08:01:43.500@ then
   return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 1;
if $rows != 4007 then
  return -1
endi

H
Haojun Liao 已提交
137
if $data00 != @70-01-01 08:01:43.500@ then
S
slguan 已提交
138 139 140 141 142 143 144 145 146
   return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 101;
print $rows
if $rows != 3907 then
  return -1
endi

H
Haojun Liao 已提交
147
if $data00 != @70-01-01 08:01:43.488@ then
S
slguan 已提交
148 149 150 151 152 153 154 155
   return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 902;
if $rows != 3106 then
  return -1
endi

H
Haojun Liao 已提交
156
if $data00 != @70-01-01 08:01:43.388@ then
S
slguan 已提交
157 158 159 160 161 162 163 164
   return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 400;
if $rows != 3608 then
  return -1
endi

H
Haojun Liao 已提交
165
if $data00 != @70-01-01 08:01:43.450@ then
S
slguan 已提交
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
   return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 4007;
if $rows != 1 then
  return -1
endi

if $data00 != @70-01-01 08:01:43.000@ then
   return -1
endi

sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 2000 offset 4008;
if $rows != 0 then
  return -1
endi

#=================================single value filter======================================
sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 0;
if $row != 8 then
   return -1
endi

if $data00 != @70-01-01 08:01:43.000@ then
  return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 1;
if $row != 7 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 2;
if $row != 6 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 4;
if $row != 4 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 7;
if $row != 1 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 8;
if $row != 0 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 9;
if $row != 0 then
   return -1
endi

#===============================single value filter, order by desc============================
sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 0;
if $row != 8 then
   return -1
endi

if $data00 != @70-01-01 08:01:43.000@ then
  return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 1;
if $row != 7 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 2;
if $row != 6 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 4;
if $row != 4 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 7;
if $row != 1 then
   return -1
endi

if $data00 != @70-01-01 08:01:43.000@ then
  return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 8;
if $row != 0 then
   return -1
endi

sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 9;
if $row != 0 then
   return -1
endi

#[tbase-695]
sql select ts,tbname from group_mt0 where ts>='1970-01-01 8:1:40' and ts<'1970-1-1 8:1:45' and c1<99999999 limit 100000 offset 5000
if $row != 35000 then
   return -1
endi

if $data00 != @70-01-01 08:01:40.000@ then
   return -1
endi

#=================================parse error sql==========================================
sql_error select ts,tbname from group_mt0 order by ts desc limit 100 offset -1;
sql_error select ts,tbname from group_mt0 order by c1 asc limit 100 offset -1;
sql_error select ts,tbname from group_mt0 order by ts desc limit -1, 100;
sql_error select ts,tbname from group_mt0 order by ts desc slimit -1, 100;
sql_error select ts,tbname from group_mt0 order by ts desc slimit 1 soffset 1;

#================================functions applys to sql===================================
sql_error select first(t1) from group_mt0;
sql_error select last(t1) from group_mt0;
sql_error select min(t1) from group_mt0;
sql_error select max(t1) from group_mt0;
sql_error select top(t1, 20) from group_mt0;
sql_error select bottom(t1, 20) from group_mt0;
sql_error select avg(t1) from group_mt0;
sql_error select percentile(t1, 50) from group_mt0;
sql_error select percentile(t1, 50) from group_mt0;
sql_error select percentile(t1, 50) from group_mt0;

#====================================tbase-722==============================================
print tbase-722
sql select spread(ts) from group_tb0;
print $data00

if $data00 != 9999.000000000 then
   return -1
endi

#====================================tbase-716==============================================
print tbase-716
sql_error select count(*) from group_tb0 where ts in ('2016-1-1 12:12:12');
sql_error select count(*) from group_tb0 where ts < '12:12:12';

#===============================sql for twa==========================================
sql_error select twa(c1) from group_tb0;
sql_error select twa(c1) from group_stb0;
sql_error select twa(c2) from group_stb0 where ts<now and ts>now-1h group by t1;
sql_error select twa(c2) from group_stb0 where ts<now and ts>now-1h group by tbname,t1;
sql_error select twa(c2) from group_stb0 group by tbname,t1;
sql_error select twa(c2) from group_stb0 group by tbname;
sql_error select twa(c2) from group_stb0 group by t1;
sql_error select twa(c2) from group_stb0 where ts<now and ts>now-1h group by t1,tbname;

#================================first/last error check================================
sql create table m1 (ts timestamp, k int) tags(a int);
sql create table tm0 using m1 tags(1);
sql create table tm1 using m1 tags(2);

sql insert into tm0 values(10000, 1) (20000, 2)(30000, 3) (40000, NULL) (50000, 2) tm1 values(10001, 2)(20000,4)(90000,9);
sql select count(*),first(k),last(k) from m1 where tbname in ('tm0') interval(1s) order by ts desc;

if $row != 5 then
    return -1
endi

if $data00 != @70-01-01 08:00:50.000@ then
    return -1
endi

if $data01 != 1 then
   return -1
endi

if $data02 != 2 then
   return -1
endi

if $data11 != 1 then
   return -1
endi

H
Haojun Liao 已提交
348
if $data12 != NULL then
S
slguan 已提交
349 350 351
   return -1
endi

H
Haojun Liao 已提交
352
if $data13 != NULL then
S
slguan 已提交
353 354 355 356 357 358 359 360 361
   return -1
endi

print =============tbase-1324
sql select a, k-k from m1
if $row != 8 then
   return -1
endi

H
Haojun Liao 已提交
362 363 364 365 366 367 368 369 370
sql select diff(k) from tm0
if $row != 3 then
   return -1
endi

if $data21 != -1 then
   return -1
endi

S
slguan 已提交
371 372 373 374 375 376 377 378 379 380 381 382 383
#error sql
sql_error select * from 1;
sql_error select 1;
sql_error select k+k;
sql_error select k+1;
sql_error select abc();
sql_error select 1 where 1=2;
sql_error select 1 limit 1;
sql_error select 1 slimit 1;
sql_error select 1 interval(1h);
sql_error select count(*);
sql_error select sum(k);
sql_error select 'abc';
H
Haojun Liao 已提交
384 385 386
sql_error select k+1,sum(k) from tm0;
sql_error select k, sum(k) from tm0;
sql_error select k, sum(k)+1 from tm0;
S
slguan 已提交
387 388 389 390

#=============================tbase-1205
sql select count(*) from tm1 where ts<now and ts>= now -1d interval(1h) fill(NULL);

H
Haojun Liao 已提交
391