nestquery.sim 18.2 KB
Newer Older
H
Haojun Liao 已提交
1 2 3 4 5 6 7 8 9 10 11
system sh/stop_dnodes.sh

system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start

sleep 100
sql connect

print ======================== dnode1 start

H
Haojun Liao 已提交
12
$dbPrefix = nest_db
H
Haojun Liao 已提交
13 14 15 16 17 18 19 20 21 22 23
$tbPrefix = nest_tb
$mtPrefix = nest_mt
$tbNum = 10
$rowNum = 10000
$totalNum = $tbNum * $rowNum

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

H
Haojun Liao 已提交
24
sql drop database if exists $db
H
Haojun Liao 已提交
25
sql create database if not exists $db
H
Haojun Liao 已提交
26

H
Haojun Liao 已提交
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
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)

$half = $tbNum / 2

$i = 0
while $i < $half
  $tb = $tbPrefix . $i

  $nextSuffix = $i + $half
  $tb1 = $tbPrefix . $nextSuffix

  sql create table $tb using $mt tags( $i )
  sql create table $tb1 using $mt tags( $nextSuffix )

  $x = 0
  while $x < $rowNum
    $y = $x * 60000
    $ms = 1600099200000 + $y
    $c = $x / 100
    $c = $c * 100
    $c = $x - $c
    $binary = 'binary . $c
    $binary = $binary . '
    $nchar = 'nchar . $c
    $nchar = $nchar . '
    sql insert into $tb values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )  $tb1 values ($ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar )
    $x = $x + 1
  endw

  $i = $i + 1
endw

sleep 100

$i = 1
$tb = $tbPrefix . $i
H
Haojun Liao 已提交
64

H
Haojun Liao 已提交
65 66
print ==============> simple nest query test
sql select count(*) from (select count(*) from nest_mt0)
H
Haojun Liao 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
if $rows != 1 then
 return -1
endi

if $data00 != 1 then
  return -1
endi

sql select count(*) from (select count(*) from nest_mt0 group by tbname)
if $rows != 1 then
  return -1
endi

if $data00 != 10 then
  return -1
endi

sql select count(*) from (select count(*) from nest_mt0 interval(10h) group by tbname)
if $rows != 1 then
  return -1
endi

H
Haojun Liao 已提交
89 90 91 92 93 94 95 96 97 98
if $data00 != 170 then
  return -1
endi

sql select sum(a) from (select count(*) a from nest_mt0 interval(10h) group by tbname)
if $rows != 1 then
  return -1
endi

if $data00 != 100000 then
H
Haojun Liao 已提交
99 100 101 102
  return -1
endi

print =================> alias name test
H
Haojun Liao 已提交
103 104 105 106 107 108 109 110 111
sql select ts from (select count(*) a from nest_tb0 interval(1h))
if $rows != 167 then
  return -1
endi

if $data00 != @20-09-15 00:00:00.000@ then
  return -1
endi

H
Haojun Liao 已提交
112 113 114 115 116
sql select count(a) from (select count(*) a from nest_tb0 interval(1h))
if $rows != 1 then
  return -1
endi

H
Haojun Liao 已提交
117
if $data00 != 167 then
H
Haojun Liao 已提交
118 119
   return -1
endi
H
Haojun Liao 已提交
120

H
Haojun Liao 已提交
121
print ================>master query + filter
122
sql select t.* from (select count(*) a from nest_tb0 interval(10h)) t where t.a <= 520;
H
Haojun Liao 已提交
123 124 125 126
if $rows != 2 then
  return -1
endi

H
Haojun Liao 已提交
127
sql select * from (select count(*) a, tbname f1 from nest_mt0 group by tbname) t where t.a<0 and f1 = 'nest_tb0';
128 129 130 131
if $rows != 0 then
  return -1
endi

H
Haojun Liao 已提交
132 133 134 135 136 137 138 139
sql select * from (select count(*) a, tbname f1 from nest_mt0 group by tbname) t where t.a>0 and f1 = 'nest_tb0';
if $rows != 1 then
  return -1
endi

if $data00 != 10000 then
  return -1
endi
140

H
Haojun Liao 已提交
141 142 143 144 145 146 147
if $data01 != @nest_tb0@ then
  return -1
endi

if $data02 != @nest_tb0@ then
  return -1
endi
H
Haojun Liao 已提交
148

149
print ===================> nest query interval
150
sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0);
H
Haojun Liao 已提交
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
sql select avg(c1) from (select * from nest_tb0) interval(3d)
if $rows != 3 then
  return -1
endi

if $data00 != @20-09-14 00:00:00.000@  then
  return -1
endi

if $data01 != 49.222222222 then
  return -1
endi

if $data10 != @20-09-17 00:00:00.000@  then
  print expect 20-09-17 00:00:00.000, actual: $data10
  return -1
endi

if $data11 != 49.685185185 then
  return -1
endi

if $data20 != @20-09-20 00:00:00.000@  then
  return -1
endi

if $data21 != 49.500000000 then
  return -1
endi

sql_error select stddev(c1) from (select c1 from nest_tb0);
sql_error select percentile(c1, 20) from (select * from nest_tb0);
D
dapan1121 已提交
184
#sql_error select interp(c1) from (select * from nest_tb0);
185 186 187 188
sql_error select derivative(val, 1s, 0) from (select c1 val from nest_tb0);
sql_error select twa(c1) from (select c1 from nest_tb0);
sql_error select irate(c1) from (select c1 from nest_tb0);
sql_error select diff(c1), twa(c1) from (select * from nest_tb0);
S
shenglian zhou 已提交
189
sql_error select mavg(c1,2), twa(c1) from (select * from nest_tb0);
S
shenglian zhou 已提交
190
sql_error select csum(c1), twa(c1) from (select * from nest_tb0);
191 192 193
sql_error select irate(c1), interp(c1), twa(c1) from (select * from nest_tb0);

sql select apercentile(c1, 50) from (select * from nest_tb0) interval(1d)
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
if $rows != 7 then
  return -1
endi

if $data00 != @20-09-15 00:00:00.000@ then
  return -1
endi

if $data01 != 47.571428571 then
  return -1
endi

if $data10 != @20-09-16 00:00:00.000@ then
  return -1
endi

if $data11 != 49.666666667 then
  return -1
endi

if $data20 != @20-09-17 00:00:00.000@ then
  return -1
endi

if $data21 != 49.000000000 then
  return -1
endi

if $data30 != @20-09-18 00:00:00.000@ then
  return -1
endi

if $data31 != 48.333333333 then
  return -1
endi

230
sql select twa(c1) from (select * from nest_tb0);
231 232 233 234 235 236 237 238
if $rows != 1 then
  return -1
endi

if $data00 != 49.500000000 then
  return -1
endi

239
sql select leastsquares(c1, 1, 1) from (select * from nest_tb0);
240 241 242 243 244 245 246 247
if $rows != 1 then
  return -1
endi

if $data00 != @{slop:0.000100, intercept:49.000000}@ then
  return -1
endi

248
sql select irate(c1) from (select * from nest_tb0);
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
if $data00 != 0.016666667 then
  return -1
endi

sql select derivative(c1, 1s, 0) from (select * from nest_tb0);
if $rows != 9999 then
  return -1
endi

if $data00 != @20-09-15 00:01:00.000@ then
  return -1
endi

if $data01 != 0.016666667 then
  return -1
endi

if $data10 != @20-09-15 00:02:00.000@ then
  return -1
endi

if $data11 != 0.016666667 then
  return -1
endi

sql select diff(c1) from (select * from nest_tb0);
if $rows != 9999 then
  return -1
endi
S
shenglian zhou 已提交
278 279 280 281
sql select mavg(c1,2) from (select * from nest_tb0);
if $rows != 9999 then
  return -1
endi
S
shenglian zhou 已提交
282 283 284 285
sql select csum(c1) from (select * from nest_tb0);
if $rows != 10000 then
  return -1
endi
286 287

sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d);
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
if $rows != 7 then
  return -1
endi

if $data00 != @20-09-15 00:00:00.000@ then
  return -1
endi

if $data01 != 48.666666667 then
  print expect 48.666666667, actual: $data01
  return -1
endi

if $data02 != 70080.000000000 then
  return -1
endi

if $data03 != 99 then
  return -1
endi

if $data04 != 0 then
  return -1
endi

if $data05 != 1440 then
  return -1
endi

if $data06 != 0 then
  print $data06
  return -1
endi

if $data07 != 1 then
  return -1
endi

if $data08 != 99.000000000 then
  print expect 99.000000000, actual: $data08
  return -1
endi

if $data10 != @20-09-16 00:00:00.000@ then
  return -1
endi

if $data11 != 49.777777778 then
  return -1
endi

if $data12 != 71680.000000000 then
  return -1
endi
342

343 344
sql select sample(x, 20) from (select c1 x from nest_tb0);

A
Alex Duan 已提交
345
sql select top(x, 20) from (select c1 x from nest_tb0);
H
Haojun Liao 已提交
346

A
Alex Duan 已提交
347
sql select bottom(x, 20) from (select c1 x from nest_tb0)
H
Haojun Liao 已提交
348

349 350 351 352
print ===================> group by + having



353 354 355
print =========================> ascending order/descending order


356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382


print =========================> nest query join
sql select a.ts,a.k,b.ts from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ;
if $rows != 10000 then
  return -1
endi

if $data00 != @20-09-15 00:00:00.000@ then
  return -1
endi

if $data01 != 1 then
  return -1
endi

if $data02 != @20-09-15 00:00:00.000@ then
  return -1
endi

if $data10 != @20-09-15 00:01:00.000@ then
  return -1
endi

if $data11 != 1 then
  return -1
endi
H
Haojun Liao 已提交
383

384 385 386 387 388 389 390 391 392 393 394 395
if $data12 != @20-09-15 00:01:00.000@ then
  return -1
endi

sql select sum(a.k), sum(b.f) from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ;
if $rows != 1 then
  return -1
endi

if $data00 != 10000 then
  return -1
endi
H
Haojun Liao 已提交
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
if $data01 != 10000 then
  return -1
endi

sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b, (select count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts
if $rows != 10000 then
  return -1
endi

if $data00 != @20-09-15 00:00:00.000@ then
  return -1
endi

if $data01 != 1 then
  return -1
endi

if $data02 != @20-09-15 00:00:00.000@ then
  return -1
endi

if $data03 != @20-09-15 00:00:00.000@ then
  return -1
endi
H
Haojun Liao 已提交
421

A
Alex Duan 已提交
422 423
sql_error select diff(val) from (select c1 val from nest_tb0);

424
sql select diff(val) from (select ts,c1 val from nest_tb0);
425 426 427 428
if $rows != 9999 then
  return -1
endi

A
Alex Duan 已提交
429
if $data00 != @20-09-15 00:01:00.000@ then
430 431 432 433 434 435 436
  return -1
endi

if $data01 != 1 then
  return -1
endi

S
shenglian zhou 已提交
437 438 439 440 441 442 443 444 445 446 447 448
sql select mavg(val, 2) from (select c1 val from nest_tb0);
if $rows != 9999 then
  return -1
endi

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

S
shenglian zhou 已提交
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
sql select csum(val) from (select c1 val from nest_tb0);
if $rows != 10000 then
  return -1
endi

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

if $data01 != 0 then
  return -1
endi

if $data41 != 10 then
  return -1
endi

466 467
sql_error select last_row(*) from (select * from nest_tb0) having c1 > 0

468 469 470 471
print ===========>td-4805
sql_error select tbname, i from (select * from nest_tb0) group by i;

sql select count(*),c1 from (select * from nest_tb0) where c1 < 2 group by c1;
H
Haojun Liao 已提交
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
if $rows != 2 then
  return -1
endi

if $data00 != 100 then
  return -1
endi

if $data01 != 0 then
  return -1
endi

if $data10 != 100 then
  return -1
endi

if $data11 != 1 then
  return -1
endi
491

H
Haojun Liao 已提交
492 493 494 495 496 497 498 499 500 501 502 503 504 505
print =====================>TD-5157
sql select twa(c1) from nest_tb1 interval(19a);
if $rows != 10000 then
  return -1
endi

if $data00 != @20-09-14 23:59:59.992@ then
  return -1
endi

if $data01 != 0.000083333 then
  return -1
endi

506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
print ======================>TD-5271
sql select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname)
if $rows != 1 then
  return -1
endi

if $data00 != 10000 then
  return -1
endi

if $data01 != 10000 then
  return -1
endi

if $data04 != 10 then
  return -1
endi

if $data05 != 100000 then
  return -1
endi

H
Haojun Liao 已提交
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
print =================>us database interval query, TD-5039
sql create database test precision 'us';
sql use test;
sql create table t1(ts timestamp, k int);
sql insert into t1 values('2020-01-01 01:01:01.000', 1) ('2020-01-01 01:02:00.000', 2);
sql select avg(k) from (select avg(k) k from t1 interval(1s)) interval(1m);
if $rows != 2 then
  return -1
endi

if $data00 != @20-01-01 01:01:00.000000@ then
  return -1
endi

if $data01 != 1.000000000 then
  return -1
endi

if $data10 != @20-01-01 01:02:00.000000@ then
  return -1
endi

if $data11 != 2.000000000 then
  return -1
endi

554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929
sql create database test2;
sql use test2;
sql create table meters (ts TIMESTAMP,a INT,b INT) TAGS (area INT);
sql CREATE TABLE t0 USING meters TAGS (0);
sql CREATE TABLE t1 USING meters TAGS (1);
sql CREATE TABLE t2 USING meters TAGS (1);
sql CREATE TABLE t3 USING meters TAGS (0);
sql insert into t0 values ('2021-09-30 15:00:00.00',0,0);
sql insert into t0 values ('2021-09-30 15:00:01.00',1,1);
sql insert into t0 values ('2021-09-30 15:00:03.00',3,3);
sql insert into t0 values ('2021-09-30 15:00:05.00',5,5);
sql insert into t0 values ('2021-09-30 15:00:07.00',7,7);
sql insert into t0 values ('2021-09-30 15:00:09.00',9,9);

sql insert into t1 values ('2021-09-30 15:00:00.00',0,0);
sql insert into t1 values ('2021-09-30 15:00:02.00',2,2);
sql insert into t1 values ('2021-09-30 15:00:04.00',4,4);
sql insert into t1 values ('2021-09-30 15:00:06.00',6,6);
sql insert into t1 values ('2021-09-30 15:00:08.00',8,8);
sql insert into t1 values ('2021-09-30 15:00:10.00',10,10);

sql insert into t2 values ('2021-09-30 15:00:00.00',0,0);
sql insert into t2 values ('2021-09-30 15:00:01.00',11,11);
sql insert into t2 values ('2021-09-30 15:00:02.00',22,22);
sql insert into t2 values ('2021-09-30 15:00:03.00',33,33);
sql insert into t2 values ('2021-09-30 15:00:04.00',44,44);
sql insert into t2 values ('2021-09-30 15:00:05.00',55,55);

sql insert into t3 values ('2021-09-30 15:00:00.00',0,0);
sql insert into t3 values ('2021-09-30 15:00:01.00',11,11);
sql insert into t3 values ('2021-09-30 15:00:02.00',22,22);
sql insert into t3 values ('2021-09-30 15:00:03.00',33,33);
sql insert into t3 values ('2021-09-30 15:00:04.00',44,44);
sql insert into t3 values ('2021-09-30 15:00:05.00',55,55);

sql select count(*) from meters interval(1s) group by tbname;
if $rows != 24 then
  return -1
endi

sql select count(*) from (select count(*) from meters interval(1s) group by tbname) interval(1s);
if $rows != 11 then
  return -1
endi
if $data00 != @21-09-30 15:00:00.000@ then
  return -1
endi
if $data01 != 4 then
  return -1
endi
if $data10 != @21-09-30 15:00:01.000@ then
  return -1
endi
if $data11 != 3 then
  return -1
endi
if $data20 != @21-09-30 15:00:02.000@ then
  return -1
endi
if $data21 != 3 then
  return -1
endi
if $data30 != @21-09-30 15:00:03.000@ then
  return -1
endi
if $data31 != 3 then
  return -1
endi
if $data40 != @21-09-30 15:00:04.000@ then
  return -1
endi
if $data41 != 3 then
  return -1
endi
if $data50 != @21-09-30 15:00:05.000@ then
  return -1
endi
if $data51 != 3 then
  return -1
endi
if $data60 != @21-09-30 15:00:06.000@ then
  return -1
endi
if $data61 != 1 then
  return -1
endi
if $data70 != @21-09-30 15:00:07.000@ then
  return -1
endi
if $data71 != 1 then
  return -1
endi
if $data80 != @21-09-30 15:00:08.000@ then
  return -1
endi
if $data81 != 1 then
  return -1
endi
if $data90 != @21-09-30 15:00:09.000@ then
  return -1
endi
if $data91 != 1 then
  return -1
endi

sql select count(*) from (select count(*) from meters interval(1s) group by area) interval(1s);
if $rows != 11 then
  return -1
endi
if $data00 != @21-09-30 15:00:00.000@ then
  return -1
endi
if $data01 != 2 then
  return -1
endi
if $data10 != @21-09-30 15:00:01.000@ then
  return -1
endi
if $data11 != 2 then
  return -1
endi
if $data20 != @21-09-30 15:00:02.000@ then
  return -1
endi
if $data21 != 2 then
  return -1
endi
if $data30 != @21-09-30 15:00:03.000@ then
  return -1
endi
if $data31 != 2 then
  return -1
endi
if $data40 != @21-09-30 15:00:04.000@ then
  return -1
endi
if $data41 != 2 then
  return -1
endi
if $data50 != @21-09-30 15:00:05.000@ then
  return -1
endi
if $data51 != 2 then
  return -1
endi
if $data60 != @21-09-30 15:00:06.000@ then
  return -1
endi
if $data61 != 1 then
  return -1
endi
if $data70 != @21-09-30 15:00:07.000@ then
  return -1
endi
if $data71 != 1 then
  return -1
endi
if $data80 != @21-09-30 15:00:08.000@ then
  return -1
endi
if $data81 != 1 then
  return -1
endi
if $data90 != @21-09-30 15:00:09.000@ then
  return -1
endi
if $data91 != 1 then
  return -1
endi


sql select sum(sa) from (select sum(a) as sa from meters interval(1s) group by tbname) interval(1s);
if $rows != 11 then
  return -1
endi
if $data00 != @21-09-30 15:00:00.000@ then
  return -1
endi
if $data01 != 0 then
  return -1
endi
if $data10 != @21-09-30 15:00:01.000@ then
  return -1
endi
if $data11 != 23 then
  return -1
endi
if $data20 != @21-09-30 15:00:02.000@ then
  return -1
endi
if $data21 != 46 then
  return -1
endi
if $data30 != @21-09-30 15:00:03.000@ then
  return -1
endi
if $data31 != 69 then
  return -1
endi
if $data40 != @21-09-30 15:00:04.000@ then
  return -1
endi
if $data41 != 92 then
  return -1
endi
if $data50 != @21-09-30 15:00:05.000@ then
  return -1
endi
if $data51 != 115 then
  return -1
endi
if $data60 != @21-09-30 15:00:06.000@ then
  return -1
endi
if $data61 != 6 then
  return -1
endi
if $data70 != @21-09-30 15:00:07.000@ then
  return -1
endi
if $data71 != 7 then
  return -1
endi
if $data80 != @21-09-30 15:00:08.000@ then
  return -1
endi
if $data81 != 8 then
  return -1
endi
if $data90 != @21-09-30 15:00:09.000@ then
  return -1
endi
if $data91 != 9 then
  return -1
endi

sql select sum(sa) from (select sum(a) as sa from meters interval(1s) group by area) interval(1s);
if $rows != 11 then
  return -1
endi
if $data00 != @21-09-30 15:00:00.000@ then
  return -1
endi
if $data01 != 0 then
  return -1
endi
if $data10 != @21-09-30 15:00:01.000@ then
  return -1
endi
if $data11 != 23 then
  return -1
endi
if $data20 != @21-09-30 15:00:02.000@ then
  return -1
endi
if $data21 != 46 then
  return -1
endi
if $data30 != @21-09-30 15:00:03.000@ then
  return -1
endi
if $data31 != 69 then
  return -1
endi
if $data40 != @21-09-30 15:00:04.000@ then
  return -1
endi
if $data41 != 92 then
  return -1
endi
if $data50 != @21-09-30 15:00:05.000@ then
  return -1
endi
if $data51 != 115 then
  return -1
endi
if $data60 != @21-09-30 15:00:06.000@ then
  return -1
endi
if $data61 != 6 then
  return -1
endi
if $data70 != @21-09-30 15:00:07.000@ then
  return -1
endi
if $data71 != 7 then
  return -1
endi
if $data80 != @21-09-30 15:00:08.000@ then
  return -1
endi
if $data81 != 8 then
  return -1
endi
if $data90 != @21-09-30 15:00:09.000@ then
  return -1
endi
if $data91 != 9 then
  return -1
endi



sql select count(*) from (select count(*) from meters interval(1s)) interval(1s);
if $rows != 11 then
  return -1
endi
if $data00 != @21-09-30 15:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data10 != @21-09-30 15:00:01.000@ then
  return -1
endi
if $data11 != 1 then
  return -1
endi
if $data20 != @21-09-30 15:00:02.000@ then
  return -1
endi
if $data21 != 1 then
  return -1
endi
if $data30 != @21-09-30 15:00:03.000@ then
  return -1
endi
if $data31 != 1 then
  return -1
endi
if $data40 != @21-09-30 15:00:04.000@ then
  return -1
endi
if $data41 != 1 then
  return -1
endi
if $data50 != @21-09-30 15:00:05.000@ then
  return -1
endi
if $data51 != 1 then
  return -1
endi
if $data60 != @21-09-30 15:00:06.000@ then
  return -1
endi
if $data61 != 1 then
  return -1
endi
if $data70 != @21-09-30 15:00:07.000@ then
  return -1
endi
if $data71 != 1 then
  return -1
endi
if $data80 != @21-09-30 15:00:08.000@ then
  return -1
endi
if $data81 != 1 then
  return -1
endi
if $data90 != @21-09-30 15:00:09.000@ then
  return -1
endi
if $data91 != 1 then
  return -1
endi

sql select count(*) from (select count(*) from meters interval(1s) group by tbname);
if $rows != 1 then
  return -1
endi
if $data00 != 24 then
  return -1
endi

D
dapan1121 已提交
930 931 932 933 934 935 936 937 938 939 940 941 942
sql select sum(a)/sum(b) from meters where ts >= '2021-09-30 15:00:00.000' and ts <= '2021-09-30 15:00:05.000' interval(1s) fill(null) group by area order by area;
if $rows != 12 then
  return -1
endi
if $data00 != @21-09-30 15:00:00.000@ then
  return -1
endi
if $data01 != NULL then
  return -1
endi
if $data02 != 0 then
  return -1
endi
943

S
shenglian zhou 已提交
944
system sh/exec.sh -n dnode1 -s stop -x SIGINT