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

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

$dbPrefix = select_tags_db
$tbPrefix = select_tags_tb
$mtPrefix = select_tags_mt

$tbNum = 16
$rowNum = 800
$totalNum = $tbNum * $rowNum

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

$tstart = 100000

sql drop database if exists $db -x step1
step1:
H
Haojun Liao 已提交
27
sql create database if not exists $db keep 36500
S
slguan 已提交
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 83 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 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
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
$j = 1

while $i < $tbNum
  $tb = $tbPrefix . $i
  $tg2 = ' . abc
  $tg2 = $tg2 . $i
  $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

    $c1 = $c + $i

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

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

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

  $i = $i + 1
  $j = $j + 10000
  $tstart = 100000 + $j

endw

sleep 100

#================================
sql select ts from select_tags_mt0
print $rows
if $rows != 12800 then
   return -1
endi

sql select first(ts), tbname, t1, t2 from select_tags_mt0;
if $rows != 1 then
   return -1
endi

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

if $data01 != @select_tags_tb0@ then
   return -1
endi

if $data02 != 0 then
   return -1
endi

if $data03 != @abc0@ then
   return -1
endi

sql select last(ts), tbname, t1, t2 from select_tags_mt0;
if $rows != 1 then
   return -1
endi

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

if $data01 != @select_tags_tb15@ then
   return -1
endi

if $data02 != 15 then
   return -1
endi

if $data03 != @abc15@ then
   return -1
endi

sql select min(c1), tbname, t1, t2 from select_tags_mt0;
if $rows != 1 then
   return -1
endi

if $data00 != 0 then
   return -1
endi

if $data01 != @select_tags_tb0@ then
   return -1
endi

if $data02 != 0 then
   return -1
endi

if $data03 != @abc0@ then
   return -1
endi

sql select max(c1), tbname, t1, t2 from select_tags_mt0;
if $rows != 1 then
   return -1
endi

if $data00 != 114 then
   return -1
endi

if $data01 != @select_tags_tb15@ then
   return -1
endi

if $data02 != 15 then
   return -1
endi

if $data03 != @abc15@ then
   return -1
endi

H
Haojun Liao 已提交
162
sql select top(c6, 3) from select_tags_mt0 interval(10a)
H
Haojun Liao 已提交
163
sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname,t1,t2
H
Haojun Liao 已提交
164
sql select top(c6, 3) from select_tags_mt0 interval(10a) group by tbname;
165

H
Haojun Liao 已提交
166 167 168 169 170
sql select top(c6, 10) from select_tags_mt0 interval(10a);
if $rows != 12800 then
  return -1
endi

S
slguan 已提交
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 348 349 350 351 352 353 354 355 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 383 384 385 386 387 388 389 390 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 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 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 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 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 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
sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0;
if $rows != 100 then
   return -1
endi

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

if $data10 != @70-01-01 08:03:30.200@ then
   return -1
endi

if $data01 != 110 then
   return -1
endi

if $data02 != @select_tags_tb11@ then
   return -1
endi

if $data03 != 11 then
   return -1
endi

if $data04 != @abc11@ then
   return -1
endi

sql select top(c1, 80), tbname, t1, t2 from select_tags_mt0;
if $rows != 80 then
   return -1
endi

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

if $data10 != @70-01-01 08:03:40.200@ then
   return -1
endi

if $data01 != 111 then
   return -1
endi

if $data02 != @select_tags_tb12@ then
   return -1
endi

if $data03 != 12 then
   return -1
endi

if $data04 != @abc12@ then
   return -1
endi

sql select bottom(c1, 100), tbname, t1, t2 from select_tags_mt0;
if $rows != 100 then
   return -1
endi

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

if $data10 != @70-01-01 08:01:40.001@ then
   return -1
endi

if $data01 != 0 then
   return -1
endi

if $data02 != @select_tags_tb0@ then
   return -1
endi

if $data03 != 0 then
   return -1
endi

if $data04 != @abc0@ then
   return -1
endi

sql select last_row(c1, c2), tbname, t1, t2 from select_tags_mt0;
if $rows != 1 then
   return -1
endi

if $data00 != 114 then
   return -1
endi

print $data01
if $data01 != 99.00000 then
   return -1
endi

if $data02 != @select_tags_tb15@ then
   return -1
endi

if $data03 != 15 then
   return -1
endi

print ====== selectivity+tags+group by tags=======================
sql select first(c1), tbname, t1, t2 from select_tags_mt0 group by tbname;
if $rows != 16 then
   return -1
endi

if $data00 != 0 then
   return -1
endi

if $data10 != 1 then
   return -1
endi

print $data01
if $data01 != @select_tags_tb0@ then
   return -1
endi

if $data11 != @select_tags_tb1@ then
   return -1
endi

if $data02 != 0 then
   return -1
endi

if $data03 != @abc0@ then
   return -1
endi

if $data04 != @select_tags_tb0@ then
   return -1
endi

sql select last_row(ts,c1), tbname, t1, t2 from select_tags_mt0 group by tbname;
if $rows != 16 then
   return -1
endi

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

if $data10 != @70-01-01 08:01:50.800@ then
   return -1
endi

print $data01
if $data01 != 99 then
   return -1
endi

if $data11 != 100 then
   return -1
endi

if $data02 != @select_tags_tb0@ then
   return -1
endi

if $data03 != 0 then
   return -1
endi

if $data04 != @abc0@ then
   return -1
endi

sql select tbname,t1,t2 from select_tags_mt0;
if $row != 16 then
   return -1
endi

if $data00 != @select_tags_tb0@ then
   return -1
endi

if $data01 != 0 then
    return -1
endi

if $data02 != @abc0@ then
    return -1
endi

if $data10 != @select_tags_tb1@ then
   return -1
endi

if $data11 != 1 then
   return -1
endi

if $data12 != @abc1@ then
   return -1
endi

sql select tbname,ts from select_tags_mt0;
if $row != 12800 then
   return -1
endi

if $data00 != @select_tags_tb0@ then
  return -1
endi

if $data10 != @select_tags_tb0@ then
   return -1
endi

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

if $data11 != @70-01-01 08:01:40.001@ then
  return -1
endi

sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname;
if $row != 200 then
  return -1
endi

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

if $data10 != @70-01-01 08:01:40.088@ then
  return -1
endi

if $data20 != @70-01-01 08:01:40.089@ then
  return -1
endi

if $data90 != @70-01-01 08:01:40.096@ then
  return -1
endi

if $data01 != 87 then
  return -1
endi

if $data02 != @select_tags_tb0@ then
  return -1
endi

if $data03 != 0 then
  return -1
endi

if $data04 != @abc0@ then
  return -1
endi

sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2;
if $row != 4 then
  return -1
endi

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

if $data01 != 99 then
   return -1
endi

if $data02 != @abc0@ then
   return -1
endi

if $data03 != @select_tags_tb0@ then
   return -1
endi

if $data04 != @abc0@ then
   return -1
endi

if $data10 != @70-01-01 08:01:40.199@ then
  return -1
endi

if $data11 != 99 then
   return -1
endi

if $data12 != @abc0@ then
   return -1
endi

if $data13 != @select_tags_tb0@ then
   return -1
endi

if $data14 != @abc0@ then
   return -1
endi

if $data20 != @70-01-01 08:01:50.100@ then
  return -1
endi

if $data21 != 100 then
   return -1
endi

if $data22 != @abc1@ then
   return -1
endi

if $data23 != @select_tags_tb1@ then
   return -1
endi

if $data24 != @abc1@ then
   return -1
endi

if $data30 != @70-01-01 08:01:50.200@ then
  return -1
endi

if $data31 != 100 then
   return -1
endi

if $data32 != @abc1@ then
   return -1
endi

if $data33 != @select_tags_tb1@ then
   return -1
endi

if $data34 != @abc1@ then
   return -1
endi


# slimit /limit
sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 limit 2 offset 1;
if $row != 2 then
  return -1
endi

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

if $data01 != 99 then
   return -1
endi

if $data02 != @abc0@ then
   return -1
endi

if $data03 != @select_tags_tb0@ then
   return -1
endi

if $data04 != @abc0@ then
   return -1
endi

print ======= selectivity + tags + group by + tags + filter ===========================
sql select first(c1), t1 from select_tags_mt0 where c1<=2 group by tbname;
if $row != 3 then
  return -1
endi

if $data00 != 0 then
  return -1
endi

if $data01 != 0 then
   return -1
endi

if $data02 != @select_tags_tb0@ then
   return -1
endi

if $data10 != 1 then
   return -1
endi

if $data11 != 1 then
   return -1
endi

if $data12 != @select_tags_tb1@ then
   return -1
endi

if $data20 != 2 then
   return -1
endi

if $data21 != 2 then
   return -1
endi

if $data22 != @select_tags_tb2@ then
   return -1
endi

sql select first(c1), tbname from select_tags_mt0 where c1<=2 interval(1s);
if $row != 3 then
   return -1
endi

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

if $data01 != 0 then
   return -1
endi

if $data02 != @select_tags_tb0@ then
   return -1
endi

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

if $data11 != 1 then
   return -1
endi

if $data12 != @select_tags_tb1@ then
   return -1
endi

if $data20 != @70-01-01 08:02:00.000@ then
   return -1
endi

if $data21 != 2 then
   return -1
endi

if $data22 != @select_tags_tb2@ then
   return -1
endi

sql select first(ts),ts from select_tags_tb0 where c1<3
if $row != 1 then
   return -1
endi

if $data00 != $data01 then
   return -1
endi

sql select last(ts),ts from select_tags_tb0 where c1<3
if $row != 1 then
   return -1
endi

if $data00 != $data01 then
   return -1
endi

H
Haojun Liao 已提交
649 650 651 652 653 654 655 656 657
sql select first(ts), ts  from select_tags_tb1
if $row != 1 then
  return -1
endi

if $data01 != @70-01-01 08:01:50.001@ then
  return -1
endi

S
slguan 已提交
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
print ======= selectivity + tags + group by + tags + filter + interval ================
sql select first(c1), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname;
if $row != 3 then
   return -1
endi

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

if $data01 != 0 then
   return -1
endi

if $data02 != @abc0@ then
   return -1
endi

if $data03 != 0 then
   return -1
endi

if $data04 != @select_tags_tb0@ then
   return -1
endi

if $data05 != @select_tags_tb0@ then
   return -1
endi

if $data15 != @select_tags_tb1@ then
   return -1
endi

if $data25 != @select_tags_tb2@ then
  return -1
endi

sql select top(c1, 5), t2 from select_tags_mt0 where c1<=2 interval(1d) group by tbname;
if $row != 15 then
   return -1
endi

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

if $data01 != 2 then
   return -1
endi

if $data02 != @abc0@ then
   return -1
endi

if $data03 != @select_tags_tb0@ then
   return -1
endi

if $data90 != @70-01-01 08:01:50.402@ then
   return -1
endi

if $data91 != 2 then
   return -1
endi

if $data92 != @abc1@ then
   return -1
endi

if $data93 != @select_tags_tb1@ then
   return -1
endi

#if data
sql select top(c1, 50), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname;
if $row != 48 then
  return -1
endi

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

if $data01 != 0 then
   return -1
endi

if $data02 != @abc0@ then
   return -1
endi

if $data03 != 0 then
   return -1
endi

if $data04 != @select_tags_tb0@ then
   return -1
endi

if $data05 != @select_tags_tb0@ then
  return -1
endi

if $data10 != @70-01-01 08:01:40.001@ then
   return -1
endi

if $data11 != 1 then
   return -1
endi

if $data12 != @abc0@ then
   return -1
endi

if $data13 != 0 then
   return -1
endi

if $data14 != @select_tags_tb0@ then
   return -1
endi

if $data15 != @select_tags_tb0@ then
  return -1
endi

if $data90 != @70-01-01 08:01:40.300@ then
   return -1
endi

if $data91 != 0 then
   return -1
endi

if $data92 != @abc0@ then
   return -1
endi

if $data93 != 0 then
   return -1
endi

if $data94 != @select_tags_tb0@ then
   return -1
endi

if $data95 != @select_tags_tb0@ then
  return -1
endi

sql select last(ts),TBNAME from select_tags_mt0 interval(1y)
if $row != 1 then
   return -1
endi

print ======= selectivity + tags+ group by + tags + filter + interval + join===========


print ======error sql=============================================
sql_error select first(*), tbname from select_tags_mt0;
sql_error select first(ts), first(c1),tbname from select_tags_mt0;
sql_error select first(ts), last(ts), tbname from select_tags_mt0;
sql_error select last_row(*), first(ts), tbname, t1, t2 from select_tags_mt0;
sql_error select tbname, last_row(*), t1, first(ts) from select_tags_mt0;
sql_error select count(*), tbname from select_tags_mt0;
sql_error select sum(c2), tbname from select_tags_mt0;
sql_error select avg(c3), tbname from select_tags_mt0;
sql_error select percentile(c3, 50), tbname from select_tags_mt0;
sql_error select apercentile(c4, 50), tbname from select_tags_mt0;
sql_error select spread(c2), tbname, t1 from select_tags_mt0;
sql_error select stddev(c2), tbname from select_tags_mt0;
sql_error select twa(c2), tbname from select_tags_mt0;
sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001;

sql_error select t1,t2,tbname from select_tags_mt0 group by tbname;
sql_error select count(tbname) from select_tags_mt0 interval(1d);
sql_error select count(tbname) from select_tags_mt0 group by t1;
sql_error select count(tbname),SUM(T1) from select_tags_mt0 interval(1d);
sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname;
sql_error select ts from select_tags_mt0 interval(1y);
sql_error select count(*), tbname from select_tags_mt0 interval(1y);
sql_error select tbname, t1 from select_tags_mt0 interval(1y);

#===error sql + group by ===============================================
#valid sql: select first(c1), last(c2), tbname from select_tags_mt0 group by tbname;
#valid sql: select first(c1), last(c2), count(*), tbname from select_tags_mt0 group by tbname;
#valid sql: select first(c1), last(c2), count(*) from select_tags_mt0 group by tbname, t1;
#valid sql: select first(c1), tbname, t1 from select_tags_mt0 group by t2;

sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
# this sql is valid: select first(c1), t2 from select_tags_mt0 group by tbname;

#sql select first(ts), tbname from select_tags_mt0 group by tbname;
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
#sql select count(*),tbname from select_tags_mt0 group by tbname
S
scripts  
Shengliang Guan 已提交
858 859

system sh/exec.sh -n dnode1 -s stop -x SIGINT