checkStreamSTable.sim 11.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1

print ===== step1

system sh/exec.sh -n dnode1 -s start 
sleep 50
sql connect

print ===== step2

sql create database result vgroups 1;

sql create database test  vgroups 4;
sql use test;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);

5
54liuyao 已提交
22
sql create stable result.streamt0(ts timestamp,a int,b int) tags(ta int,tb varchar(100),tc int);
23

5
54liuyao 已提交
24
sql create stream streams0 trigger at_once  into result.streamt0 tags(tb) as select  _wstart, count(*) c1, max(a) c2 from st partition by tbname tb interval(10s);
25 26 27 28 29 30 31 32 33 34 35 36
sql insert into t1 values(1648791213000,1,2,3);
sql insert into t2 values(1648791213000,2,2,3);

$loop_count = 0

sql select  _wstart, count(*) c1, max(a) c2 from st partition by tbname interval(10s);
print $data00, $data01, $data02
print $data10, $data11, $data12
print $data20, $data21, $data22

loop0:

5
54liuyao 已提交
37
sleep 1000
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

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from result.streamt0 order by ta;

if $rows != 2 then
  print =====rows=$rows
  print $data00, $data01, $data02
  print $data10, $data11, $data12
  print $data20, $data21, $data22
  goto loop0
endi

if $data01 != 1 then
  print =====data01=$data01
  goto loop0
endi

if $data02 != 1 then
  print =====data02=$data02
  goto loop0
endi

5
54liuyao 已提交
64 65 66 67 68 69 70 71 72 73
if $data03 != NULL then
  print =====data03=$data03
  goto loop0
endi

if $data04 != t1 then
  print =====data04=$data04
  goto loop0
endi

74 75 76 77 78 79 80 81 82 83
if $data11 != 1 then
  print =====data11=$data11
  goto loop0
endi

if $data12 != 2 then
  print =====data12=$data12
  goto loop0
endi

5
54liuyao 已提交
84 85 86 87 88 89 90 91 92 93
if $data13 != NULL then
  print =====data13=$data13
  goto loop0
endi

if $data14 != t2 then
  print =====data14=$data14
  goto loop0
endi

94 95 96 97 98 99 100 101 102 103 104 105
print ===== step3

sql create database result1 vgroups 1;

sql create database test1  vgroups 4;
sql use test1;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);

5
54liuyao 已提交
106
sql create stable result1.streamt1(ts timestamp,a int,b int,c int) tags(ta varchar(100),tb int,tc int);
107

5
54liuyao 已提交
108
sql create stream streams1 trigger at_once  into result1.streamt1(ts,c,a,b) tags(ta) as select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname as ta interval(10s);
109 110 111 112 113 114 115 116 117 118 119 120
sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);

$loop_count = 0

sql select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname interval(10s);
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

loop1:

5
54liuyao 已提交
121
sleep 1000
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from result1.streamt1 order by ta;

if $rows != 2 then
  print =====rows=$rows
  print $data00, $data01, $data02, $data03
  print $data10, $data11, $data12, $data13
  print $data20, $data21, $data22, $data23
  goto loop1
endi

if $data01 != 10 then
  print =====data01=$data01
  goto loop1
endi

if $data02 != 20 then
  print =====data02=$data02
  goto loop1
endi

if $data03 != 1 then
  print =====data03=$data03
  goto loop1
endi

if $data11 != 40 then
  print =====data11=$data11
  goto loop1
endi

if $data12 != 50 then
  print =====data12=$data12
  goto loop1
endi

if $data13 != 1 then
  print =====data13=$data13
  goto loop1
endi


print ===== step4

sql create database result2 vgroups 1;

sql create database test2  vgroups 4;
sql use test2;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);

sql create stable result2.streamt2(ts timestamp, a int , b int) tags(ta varchar(20));

# tag dest 1, source 2
5
54liuyao 已提交
184
sql_error create stream streams2 trigger at_once  into result2.streamt2 TAGS(aa varchar(100), ta int) as select  _wstart, count(*) c1, max(a) from st partition by tbname as aa, ta interval(10s);
185 186 187 188 189 190 191 192 193 194 195

# column dest 3, source 4
sql_error create stream streams2 trigger at_once  into result2.streamt2 as select  _wstart, count(*) c1, max(a), max(b) from st partition by tbname interval(10s);

# column dest 3, source 4
sql_error create stream streams2 trigger at_once  into result2.streamt2(ts, a, b) as select  _wstart, count(*) c1, max(a), max(b) from st partition by tbname interval(10s);

# column dest 3, source 2
sql_error create stream streams2 trigger at_once  into result2.streamt2 as select  _wstart, count(*) c1 from st partition by tbname interval(10s);

# column dest 3, source 2
5
54liuyao 已提交
196
sql create stream streams2 trigger at_once  into result2.streamt2(ts, a) tags(ta) as select  _wstart, count(*) c1 from st partition by tbname as ta interval(10s);
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


print ===== step5

sql create database result3 vgroups 1;

sql create database test3  vgroups 4;
sql use test3;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,2,3);
sql create table t2 using st tags(4,5,6);

sql create stable result3.streamt3(ts timestamp,a int,b int,c int, d int) tags(ta int,tb int,tc int);

sql create stream streams3 trigger at_once  into result3.streamt3(ts,c,a,b) as select  _wstart, count(*) c1, max(a),min(b) c2 from st interval(10s);

sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);

$loop_count = 0

sql select  _wstart, count(*) c1, max(a),min(b) c2 from st interval(10s);
print $data00, $data01, $data02, $data03, $data04
print $data10, $data11, $data12, $data13, $data14
print $data20, $data21, $data22, $data23, $data24

loop2:

5
54liuyao 已提交
227
sleep 1000
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

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from result3.streamt3;

if $rows != 1 then
  print =====rows=$rows
  print $data00, $data01, $data02, $data03
  print $data10, $data11, $data12, $data13
  print $data20, $data21, $data22, $data23
  goto loop2
endi

if $data01 != 40 then
  print =====data01=$data01
  goto loop2
endi

if $data02 != 20 then
  print =====data02=$data02
  goto loop2
endi

if $data03 != 2 then
  print =====data03=$data03
  goto loop2
endi

if $data04 != NULL then
  print =====data04=$data04
  goto loop2
endi

5
54liuyao 已提交
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
print ===== drop ...

sql drop stream if exists streams0;
sql drop stream if exists streams1;
sql drop stream if exists streams2;
sql drop stream if exists streams3;
sql drop database if exists test;
sql drop database if exists test1;
sql drop database if exists test2;
sql drop database if exists test3;
sql drop database if exists result;
sql drop database if exists result1;
sql drop database if exists result2;
sql drop database if exists result3;

279 280 281 282 283 284 285 286 287 288 289
print ===== step6

sql create database result4 vgroups 1;

sql create database test4  vgroups 4;
sql use test4;

sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,2,3);
sql create table t2 using st tags(4,5,6);

5
54liuyao 已提交
290
sql create stable result4.streamt4(ts timestamp,a int,b int,c int, d int) tags(tg1 int,tg2 int,tg3 int);
291

5
54liuyao 已提交
292
sql create stream streams4 trigger at_once  into result4.streamt4(ts,c,a,b) tags(tg2, tg3, tg1) subtable( concat("tbl-", cast(tg1 as varchar(10)) ) )  as select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
293 294 295 296 297 298

sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);

$loop_count = 0

5
54liuyao 已提交
299
sql select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
300 301 302 303
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

5
54liuyao 已提交
304
loop3:
305

5
54liuyao 已提交
306
sleep 1000
307 308 309 310 311 312

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

5
54liuyao 已提交
313
sql select * from result4.streamt4 order by tg1;
314 315 316 317 318 319

if $rows != 2 then
  print =====rows=$rows
  print $data00, $data01, $data02, $data03
  print $data10, $data11, $data12, $data13
  print $data20, $data21, $data22, $data23
5
54liuyao 已提交
320
  goto loop3
321 322
endi

5
54liuyao 已提交
323
if $data01 != 10 then
324
  print =====data01=$data01
5
54liuyao 已提交
325
  goto loop3
326 327 328 329
endi

if $data02 != 20 then
  print =====data02=$data02
5
54liuyao 已提交
330
  goto loop3
331 332
endi

5
54liuyao 已提交
333
if $data03 != 1 then
334
  print =====data03=$data03
5
54liuyao 已提交
335
  goto loop3
336 337 338 339
endi

if $data04 != NULL then
  print =====data04=$data04
5
54liuyao 已提交
340
  goto loop3
341 342
endi

5
54liuyao 已提交
343 344
if $data11 != 40 then
  print =====data11=$data11
5
54liuyao 已提交
345
  goto loop3
5
54liuyao 已提交
346 347 348 349
endi

if $data12 != 50 then
  print =====data12=$data12
5
54liuyao 已提交
350
  goto loop3
5
54liuyao 已提交
351 352 353 354
endi

if $data13 != 1 then
  print =====data13=$data13
5
54liuyao 已提交
355
  goto loop3
5
54liuyao 已提交
356 357 358 359
endi

if $data14 != NULL then
  print =====data14=$data14
5
54liuyao 已提交
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
  goto loop3
endi

print ===== step7

sql create database result5 vgroups 1;

sql create database test5  vgroups 4;
sql use test5;

sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,2,3);
sql create table t2 using st tags(4,5,6);

sql create stable result5.streamt5(ts timestamp,a int,b int,c int, d int) tags(tg1 int,tg2 int,tg3 int);

sql create stream streams5 trigger at_once  into result5.streamt5(ts,c,a,b) tags(tg2, tg3, tg1) subtable( concat("tbl-", cast(tg3 as varchar(10)) ) )  as select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, a as tg3 session(ts, 10s);

sql insert into t1 values(1648791213000,NULL,NULL,NULL);

$loop_count = 0

print select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, a as tg3 session(ts, 10s);
sql select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, a as tg3 session(ts, 10s);
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

loop4:

5
54liuyao 已提交
390
sleep 1000
5
54liuyao 已提交
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

print sql select * from result5.streamt5 order by tg1;
sql select * from result5.streamt5 order by tg1;
print $data00, $data01, $data02, $data03 $data04 $data05 $data06 $data07
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

if $rows != 1 then
  print =====rows=$rows
  goto loop4
endi

if $data01 != NULL then
  print =====data01=$data01
  goto loop4
endi

if $data02 != NULL then
  print =====data02=$data02
  goto loop4
endi

if $data03 != 1 then
  print =====data03=$data03
  goto loop4
endi

if $data04 != NULL then
  print =====data04=$data04
  goto loop4
endi

if $data05 != 2 then
  print =====data05=$data05
  goto loop4
endi

if $data06 != 2 then
  print =====data06=$data06
  goto loop4
endi

if $data07 != NULL then
  print =====data07=$data07
  goto loop4
5
54liuyao 已提交
441 442
endi

5
54liuyao 已提交
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
sql drop stream if exists streams4;
sql drop stream if exists streams5;
sql drop database if exists test4;
sql drop database if exists test5;
sql drop database if exists result4;
sql drop database if exists result5;

print ===== step8

sql drop stream if exists streams8;
sql drop database if exists test8;
sql create database test8  vgroups 1;
sql use test8;
sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams8 trigger at_once  into streamt8 as select  _wstart as ts, count(*) c1, count(d) c2, count(c) c3  from t1 partition by tbname interval(10s) ;

sql drop stream streams8;
sql create stream streams71 trigger at_once  into streamt8(ts, c2) tags(group_id)as select _wstart, count(*) from t1 partition by tbname as group_id interval(10s);

sql insert into t1 values(1648791233000,1,2,3,1.0);

loop8:

5
54liuyao 已提交
466
sleep 1000
5
54liuyao 已提交
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from streamt8;
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

if $rows != 1 then
  print =====rows=$rows
  goto loop8
endi

if $data01 != NULL then
  print =====data01=$data01
  goto loop8
endi

if $data02 != 1 then
  print =====data02=$data02
  goto loop8
endi

if $data03 != NULL then
  print =====data03=$data03
  goto loop8
endi

498 499 500
print ======over

system sh/stop_dnodes.sh