diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 1ef6d55b2755c68b81c9d0e3108e2f0f4dc12956..a13a757bbe073c85bc33f0ac88cc966901be3bf6 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -89,7 +89,7 @@ ./test.sh -f tsim/parser/alter.sim # jira ./test.sh -f tsim/parser/alter1.sim ./test.sh -f tsim/parser/auto_create_tb_drop_tb.sim -# jira ./test.sh -f tsim/parser/auto_create_tb.sim +./test.sh -f tsim/parser/auto_create_tb.sim ./test.sh -f tsim/parser/between_and.sim ./test.sh -f tsim/parser/binary_escapeCharacter.sim # jira ./test.sh -f tsim/parser/col_arithmetic_operation.sim @@ -121,25 +121,21 @@ ./test.sh -f tsim/parser/insert_multiTbl.sim ./test.sh -f tsim/parser/insert_tb.sim # jira ./test.sh -f tsim/parser/interp.sim -# ./test.sh -f tsim/parser/join.sim -# ./test.sh -f tsim/parser/join_manyblocks.sim +./test.sh -f tsim/parser/join_manyblocks.sim ## ./test.sh -f tsim/parser/join_multitables.sim # ./test.sh -f tsim/parser/join_multivnode.sim +# jira ./test.sh -f tsim/parser/join.sim ./test.sh -f tsim/parser/last_cache.sim -## ./test.sh -f tsim/parser/last_groupby.sim +./test.sh -f tsim/parser/last_groupby.sim # jira ./test.sh -f tsim/parser/lastrow.sim -## ./test.sh -f tsim/parser/like.sim -# ./test.sh -f tsim/parser/limit.sim -# ./test.sh -f tsim/parser/limit1.sim -# ./test.sh -f tsim/parser/limit1_tblocks100.sim -## ./test.sh -f tsim/parser/limit2.sim -## ./test.sh -f tsim/parser/limit2_tblocks100.sim -## ./test.sh -f tsim/parser/limit_stb.sim -## ./test.sh -f tsim/parser/limit_tb.sim -## ./test.sh -f tsim/parser/line_insert.sim +./test.sh -f tsim/parser/like.sim +# jira ./test.sh -f tsim/parser/limit.sim +# jira ./test.sh -f tsim/parser/limit1.sim +# jira ./test.sh -f tsim/parser/limit2.sim +# jira ./test.sh -f tsim/parser/line_insert.sim ./test.sh -f tsim/parser/mixed_blocks.sim ./test.sh -f tsim/parser/nchar.sim -# ./test.sh -f tsim/parser/nestquery.sim +# jira ./test.sh -f tsim/parser/nestquery.sim # jira ./test.sh -f tsim/parser/null_char.sim ./test.sh -f tsim/parser/precision_ns.sim ./test.sh -f tsim/parser/projection_limit_offset.sim @@ -165,7 +161,8 @@ # jira ./test.sh -f tsim/parser/udf_dll_stable.sim # jira ./test.sh -f tsim/parser/udf_dll.sim # jira ./test.sh -f tsim/parser/udf.sim -# ./test.sh -f tsim/parser/union.sim +./test.sh -f tsim/parser/union.sim +# jira ./test.sh -f tsim/parser/union_sysinfo.sim # jira ./test.sh -f tsim/parser/where.sim # ---- query diff --git a/tests/script/tsim/parser/auto_create_tb.sim b/tests/script/tsim/parser/auto_create_tb.sim index 485f4f480cf9112dd0240e33b96558ac86b71c81..3a64b7923991149d7c401189f1d4614af2cf01e2 100644 --- a/tests/script/tsim/parser/auto_create_tb.sim +++ b/tests/script/tsim/parser/auto_create_tb.sim @@ -282,7 +282,7 @@ if $rows != 2 then return -1 endi -sql insert into tick_000001 ('ts', 'last_prc', 'volume', 'amount', 'oi', 'bid_prc1', 'ask_prc1') using tick tags (000001, Stocks) VALUES (1546391700000, 0.000000, 0, 0.000000, 0, 0.000000, 10.320000); +sql insert into tick_000001 (ts, last_prc, volume, amount, oi, bid_prc1, ask_prc1) using tick tags ('000001', 'Stocks') VALUES (1546391700000, 0.000000, 0, 0.000000, 0, 0.000000, 10.320000); sql select tbname from tick if $rows != 1 then return -1 diff --git a/tests/script/tsim/parser/join.sim b/tests/script/tsim/parser/join.sim index 55842d5c16fb757c5c5015e81117e40224a5a693..fa03ad8214eefdabbfde829e156e711c2c0e3e19 100644 --- a/tests/script/tsim/parser/join.sim +++ b/tests/script/tsim/parser/join.sim @@ -233,8 +233,15 @@ endi print 1 #select + where condition + interval query -sql select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by join_tb0.ts desc; +print select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by _wstart asc; +sql select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by _wstart asc; +$val = 100 +if $rows != $val then + return -1 +endi +print select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by _wstart desc; +sql select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by _wstart desc; $val = 100 if $rows != $val then return -1 diff --git a/tests/script/tsim/parser/join_manyblocks.sim b/tests/script/tsim/parser/join_manyblocks.sim index eb5e34b07991bebe5d31319ef9a31f26d9bdb9a5..154316a03f694d7ea375f1cc7d3cc4ad903cd9b9 100644 --- a/tests/script/tsim/parser/join_manyblocks.sim +++ b/tests/script/tsim/parser/join_manyblocks.sim @@ -73,8 +73,6 @@ while $i < $tbNum $tstart = 100000 endw -sleep 100 - print ===============join_manyblocks.sim print ==============> td-3313 sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1; diff --git a/tests/script/tsim/parser/last_groupby.sim b/tests/script/tsim/parser/last_groupby.sim index 8f9574412d4e1bfe6d9c9d2bacb5402fc3596e0b..68d7f10fe28b41b4ee10088d18f321e85131e17d 100644 --- a/tests/script/tsim/parser/last_groupby.sim +++ b/tests/script/tsim/parser/last_groupby.sim @@ -4,14 +4,11 @@ system sh/exec.sh -n dnode1 -s start sql connect print ======================== dnode1 start - $db = testdb - sql create database $db sql use $db sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10)) - sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1"); sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true,"1","1") @@ -23,16 +20,13 @@ sql insert into tb1 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4") sql insert into tb1 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4") sql insert into tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4") -sql select f1,last(*) from st2 group by f1; - +sql select f1, last(*) from st2 group by f1 order by f1; if $rows != 4 then return -1 endi - if $data00 != 1 then return -1 endi - if $data02 != 1 then print $data02 return -1 @@ -59,15 +53,13 @@ if $data09 != 1 then return -1 endi -sql select f1,last(f1,st2.*) from st2 group by f1; +sql select f1, last(f1,st2.*) from st2 group by f1 order by f1; if $rows != 4 then return -1 endi - if $data00 != 1 then return -1 endi - if $data01 != 1 then return -1 endi diff --git a/tests/script/tsim/parser/like.sim b/tests/script/tsim/parser/like.sim index e7c191ed92141798ae8f1ec7e3541ec3af843c5d..96672aee3c5501015444c4b1319de7453c47e50b 100644 --- a/tests/script/tsim/parser/like.sim +++ b/tests/script/tsim/parser/like.sim @@ -5,7 +5,6 @@ sql connect print ======================== dnode1 start - $db = testdb sql drop database if exists $db sql create database $db cachemodel 'last_value' @@ -32,7 +31,6 @@ if $rows != 2 then return -1 endi - sql select b from $table1 where b like 'table\_name' if $rows != 1 then return -1 diff --git a/tests/script/tsim/parser/limit1.sim b/tests/script/tsim/parser/limit1.sim index 1f7299978450adaa34e57ea69eaaa170a59a31ea..b6d0629c8ff51dc22ce737ec736ca08bca3895ad 100644 --- a/tests/script/tsim/parser/limit1.sim +++ b/tests/script/tsim/parser/limit1.sim @@ -18,7 +18,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db +sql create database $db cache 16 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) @@ -57,11 +57,10 @@ run tsim/parser/limit1_stb.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 500 system sh/exec.sh -n dnode1 -s start print ================== server restart completed run tsim/parser/limit1_tb.sim run tsim/parser/limit1_stb.sim -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/limit1_stb.sim b/tests/script/tsim/parser/limit1_stb.sim index 513e2fac026c0d1d617ba4126d22c01f82527ca0..879fd7882fffc108e9e4446e6c037bd95af37ec5 100644 --- a/tests/script/tsim/parser/limit1_stb.sim +++ b/tests/script/tsim/parser/limit1_stb.sim @@ -1,4 +1,3 @@ -sleep 100 sql connect $dbPrefix = lm1_db diff --git a/tests/script/tsim/parser/limit1_tb.sim b/tests/script/tsim/parser/limit1_tb.sim index 300af7ac7b669088094c0ba72288f42d34ca374d..5a7c1bc2018019f9a0023040412651b2e138c07f 100644 --- a/tests/script/tsim/parser/limit1_tb.sim +++ b/tests/script/tsim/parser/limit1_tb.sim @@ -1,4 +1,3 @@ -sleep 100 sql connect $dbPrefix = lm1_db diff --git a/tests/script/tsim/parser/limit1_tblocks100.sim b/tests/script/tsim/parser/limit1_tblocks100.sim deleted file mode 100644 index f541ea7158f531eda792580df53c20079a1fd7a3..0000000000000000000000000000000000000000 --- a/tests/script/tsim/parser/limit1_tblocks100.sim +++ /dev/null @@ -1,67 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -$dbPrefix = lm1_db -$tbPrefix = lm1_tb -$stbPrefix = lm1_stb -$tbNum = 10 -$rowNum = 10000 -$totalNum = $tbNum * $rowNum -$ts0 = 1537146000000 -$delta = 600000 -print ========== limit1.sim -$i = 0 -$db = $dbPrefix . $i -$stb = $stbPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db cache 16 -print ====== create tables -sql use $db -sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) - -$i = 0 -$ts = $ts0 -$halfNum = $tbNum / 2 -while $i < $halfNum - $tbId = $i + $halfNum - $tb = $tbPrefix . $i - $tb1 = $tbPrefix . $tbId - sql create table $tb using $stb tags( $i ) - sql create table $tb1 using $stb tags( $tbId ) - - $x = 0 - while $x < $rowNum - $xs = $x * $delta - $ts = $ts0 + $xs - $c = $x / 10 - $c = $c * 10 - $c = $x - $c - $binary = 'binary . $c - $binary = $binary . ' - $nchar = 'nchar . $c - $nchar = $nchar . ' - sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) - $x = $x + 1 - endw - - $i = $i + 1 -endw -print ====== tables created - -run tsim/parser/limit1_tb.sim -run tsim/parser/limit1_stb.sim - -print ================== restart server to commit data into disk -system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 500 -system sh/exec.sh -n dnode1 -s start -print ================== server restart completed - -run tsim/parser/limit1_tb.sim -run tsim/parser/limit1_stb.sim - -system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/limit2.sim b/tests/script/tsim/parser/limit2.sim index af03c6bb7febb0fea95ceeeb4b86280efc946920..ca308fa6e7801918e4c366b511944f9afffe4970 100644 --- a/tests/script/tsim/parser/limit2.sim +++ b/tests/script/tsim/parser/limit2.sim @@ -1,10 +1,6 @@ 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/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 system sh/exec.sh -n dnode1 -s start -sleep 100 sql connect $dbPrefix = lm2_db @@ -69,10 +65,8 @@ print ====== tables created print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 500 +sleep 100 system sh/exec.sh -n dnode1 -s start print ================== server restart completed run tsim/parser/limit2_query.sim - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/parser/limit2_query.sim b/tests/script/tsim/parser/limit2_query.sim index c35fd369ca33eb7158ed3223a40f37c522702bc5..8a2da7988d9a10749f209f205ccc0eb18518e5d0 100644 --- a/tests/script/tsim/parser/limit2_query.sim +++ b/tests/script/tsim/parser/limit2_query.sim @@ -1,4 +1,3 @@ -sleep 100 sql connect $dbPrefix = lm2_db @@ -24,8 +23,11 @@ sql use $db ##### aggregation on stb with 6 tags + where + group by + limit offset $val1 = 1 $val2 = $tbNum - 1 -sql select count(*) from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 +print select count(*) from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 +sql select count(*), t1, t2, t3, t4, t5, t6 from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 $val = $tbNum - 3 + +print $rows $val if $rows != $val then return -1 endi diff --git a/tests/script/tsim/parser/limit2_tblocks100.sim b/tests/script/tsim/parser/limit2_tblocks100.sim deleted file mode 100644 index 0d87a41838002be3d9d2a4704070df63d3594fac..0000000000000000000000000000000000000000 --- a/tests/script/tsim/parser/limit2_tblocks100.sim +++ /dev/null @@ -1,76 +0,0 @@ -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/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 -system sh/exec.sh -n dnode1 -s start -sleep 100 -sql connect - -$dbPrefix = lm2_db -$tbPrefix = lm2_tb -$stbPrefix = lm2_stb -$tbNum = 10 -$rowNum = 10000 -$totalNum = $tbNum * $rowNum -$ts0 = 1537146000000 -$delta = 600000 -$tsu = $rowNum * $delta -$tsu = $tsu - $delta -$tsu = $tsu + $ts0 - -print ========== limit2.sim -$i = 0 -$db = $dbPrefix . $i -$stb = $stbPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db tblocks 100 -print ====== create tables -sql use $db -sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) - -$i = 0 -$ts = $ts0 -$halfNum = $tbNum / 2 -while $i < $halfNum - $i1 = $i + $halfNum - $tb = $tbPrefix . $i - $tb1 = $tbPrefix . $i1 - $tgstr = 'tb . $i - $tgstr = $tgstr . ' - $tgstr1 = 'tb . $i1 - $tgstr1 = $tgstr1 . ' - sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) - sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) - - $x = 0 - while $x < $rowNum - $xs = $x * $delta - $ts = $ts0 + $xs - $c = $x / 10 - $c = $c * 10 - $c = $x - $c - $binary = 'binary . $c - $binary = $binary . ' - $nchar = 'nchar . $c - $nchar = $nchar . ' - sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) - sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) - $x = $x + 1 - endw - - $i = $i + 1 -endw -print ====== tables created - -#run tsim/parser/limit2_query.sim - -print ================== restart server to commit data into disk -system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 100 -system sh/exec.sh -n dnode1 -s start -print ================== server restart completed - -run tsim/parser/limit2_query.sim diff --git a/tests/script/tsim/parser/limit_stb.sim b/tests/script/tsim/parser/limit_stb.sim index ec7c0e0f138e677c7da95c20af4bd13908aa1a0c..a3064d59e9b5d7540a70f23721198b1e2da61f12 100644 --- a/tests/script/tsim/parser/limit_stb.sim +++ b/tests/script/tsim/parser/limit_stb.sim @@ -1,4 +1,3 @@ -sleep 100 sql connect $dbPrefix = lm_db diff --git a/tests/script/tsim/parser/limit_tb.sim b/tests/script/tsim/parser/limit_tb.sim index 4a93797d40fb65a7df9ad8d18c60292bed83dfe4..d0d14c5bfc25a5942b77df7c8654e769930a0eeb 100644 --- a/tests/script/tsim/parser/limit_tb.sim +++ b/tests/script/tsim/parser/limit_tb.sim @@ -1,4 +1,3 @@ -sleep 100 sql connect $dbPrefix = lm_db diff --git a/tests/script/tsim/parser/line_insert.sim b/tests/script/tsim/parser/line_insert.sim index cbd960bed688826eafbb5bdb17911123fd209a1c..fc522ecaa7dfcd926c2ec393710ecc824ba638ca 100644 --- a/tests/script/tsim/parser/line_insert.sim +++ b/tests/script/tsim/parser/line_insert.sim @@ -43,7 +43,7 @@ endi #print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/parser/nestquery.sim b/tests/script/tsim/parser/nestquery.sim index c82718c1cb86e0470387b0895d5dcd58e55fb9df..82d39eff8eeb2eadfd21b4dd1d36c5b81a25e63c 100644 --- a/tests/script/tsim/parser/nestquery.sim +++ b/tests/script/tsim/parser/nestquery.sim @@ -53,8 +53,6 @@ while $i < $half $i = $i + 1 endw -sleep 100 - $i = 1 $tb = $tbPrefix . $i @@ -63,7 +61,6 @@ sql select count(*) from (select count(*) from nest_mt0) if $rows != 1 then return -1 endi - if $data00 != 1 then return -1 endi @@ -72,35 +69,31 @@ 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) +sql select count(*) from (select count(*) from nest_mt0 partition by tbname interval(10h) ) if $rows != 1 then return -1 endi - if $data00 != 170 then return -1 endi -sql select sum(a) from (select count(*) a from nest_mt0 interval(10h) group by tbname) +sql select sum(a) from (select count(*) a from nest_mt0 partition by tbname interval(10h)) if $rows != 1 then return -1 endi - if $data00 != 100000 then return -1 endi print =================> alias name test -sql select ts from (select count(*) a from nest_tb0 interval(1h)) +sql select ts from (select _wstart as ts, 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 @@ -109,7 +102,6 @@ sql select count(a) from (select count(*) a from nest_tb0 interval(1h)) if $rows != 1 then return -1 endi - if $data00 != 167 then return -1 endi @@ -125,19 +117,16 @@ if $rows != 0 then return -1 endi -sql select * from (select count(*) a, tbname f1 from nest_mt0 group by tbname) t where t.a>0 and f1 = 'nest_tb0'; +sql select * from (select count(*) a, tbname f1, tbname 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 - if $data01 != @nest_tb0@ then return -1 endi - if $data02 != @nest_tb0@ then return -1 endi @@ -145,37 +134,30 @@ endi print ===================> nest query interval sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0); -sql select avg(c1) from (select * from nest_tb0) interval(3d) +sql select _wstart, 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 +if $data11 != 49.581325301 then return -1 endi - if $data20 != @20-09-20 00:00:00.000@ then return -1 endi - -if $data21 != 49.500000000 then +if $data21 != 49.703539823 then return -1 endi -sql_error select stddev(c1) from (select c1 from nest_tb0); +sql select stddev(c1) from (select c1 from nest_tb0); sql_error select percentile(c1, 20) from (select * from nest_tb0); sql_error select interp(c1) from (select * from nest_tb0); sql_error select derivative(val, 1s, 0) from (select c1 val from nest_tb0); @@ -184,39 +166,31 @@ sql_error select irate(c1) from (select c1 from nest_tb0); sql_error select diff(c1), twa(c1) from (select * from nest_tb0); 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) +sql select _wstart, apercentile(c1, 50) from (select * from nest_tb0) interval(1d) 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 @@ -225,7 +199,6 @@ sql select twa(c1) from (select * from nest_tb0); if $rows != 1 then return -1 endi - if $data00 != 49.500000000 then return -1 endi @@ -234,7 +207,6 @@ sql select leastsquares(c1, 1, 1) from (select * from nest_tb0); if $rows != 1 then return -1 endi - if $data00 != @{slop:0.000100, intercept:49.000000}@ then return -1 endi @@ -248,19 +220,15 @@ 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 @@ -274,54 +242,42 @@ sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spre 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 @@ -332,39 +288,28 @@ sql select bottom(x, 20) from (select c1 x from nest_tb0) print ===================> group by + having - - print =========================> ascending order/descending order - - - 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 - if $data12 != @20-09-15 00:01:00.000@ then return -1 endi @@ -373,11 +318,9 @@ sql select sum(a.k), sum(b.f) from (select count(*) k from nest_tb0 interval(30a if $rows != 1 then return -1 endi - if $data00 != 10000 then return -1 endi - if $data01 != 10000 then return -1 endi @@ -386,19 +329,15 @@ sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select count(*) k from nest_tb0 int 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 @@ -407,11 +346,9 @@ sql select diff(val) 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 != 1 then return -1 endi @@ -425,19 +362,15 @@ sql select count(*),c1 from (select * from nest_tb0) where c1 < 2 group by c1; 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 @@ -447,11 +380,9 @@ 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 @@ -461,19 +392,15 @@ sql select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) f 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 @@ -487,19 +414,15 @@ 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 diff --git a/tests/script/tsim/parser/union.sim b/tests/script/tsim/parser/union.sim index 4d05d4ced7ca41b5e4135ab8b41dc41b297838c7..95150616d110e9f8d8964560f1483868989ecdd4 100644 --- a/tests/script/tsim/parser/union.sim +++ b/tests/script/tsim/parser/union.sim @@ -102,11 +102,11 @@ $i = 1 $tb = $tbPrefix . $i ## column type not identical -sql_error select count(*) as a from union_mt0 union all select avg(c1) as a from union_mt0 -sql_error select count(*) as a from union_mt0 union all select spread(c1) as a from union_mt0; +sql select count(*) as a from union_mt0 union all select avg(c1) as a from union_mt0 +sql select count(*) as a from union_mt0 union all select spread(c1) as a from union_mt0; ## union not supported -sql_error (select count(*) from union_mt0) union (select count(*) from union_mt0); +sql (select count(*) from union_mt0) union (select count(*) from union_mt0); ## column type not identical sql_error select c1 from union_mt0 limit 10 union all select c2 from union_tb1 limit 20; @@ -123,145 +123,114 @@ sql (((select c1 from union_tb0))) if $rows != 10000 then return -1 endi - if $data00 != 0 then return -1 endi - if $data10 != 1 then return -1 endi -sql select 'ab' as options from union_tb1 limit 1 union all select 'dd' as options from union_tb0 limit 1; +sql (select 'ab' as options from union_tb1 limit 1) union all (select 'dd' as options from union_tb0 limit 1) order by options; if $rows != 2 then return -1 endi - if $data00 != @ab@ then return -1 endi - if $data10 != @dd@ then return -1 endi - -sql select 'ab' as options from union_tb1 limit 1 union all select '1234567' as options from union_tb0 limit 1; +sql (select 'ab12345' as options from union_tb1 limit 1) union all (select '1234567' as options from union_tb0 limit 1) order by options desc; if $rows != 2 then return -1 endi - -if $data00 != @ab@ then +if $data00 != @ab12345@ then return -1 endi - if $data10 != @1234567@ then return -1 endi - # mixed order -sql select ts, c1 from union_tb1 order by ts asc limit 10 union all select ts, c1 from union_tb0 order by ts desc limit 2 union all select ts, c1 from union_tb2 order by ts asc limit 10 +sql (select ts, c1 from union_tb1 order by ts asc limit 10) union all (select ts, c1 from union_tb0 order by ts desc limit 2) union all (select ts, c1 from union_tb2 order by ts asc limit 10) order by ts if $rows != 22 then return -1 endi - if $data00 != @20-01-05 13:51:24.000@ then return -1 endi - if $data01 != 0 then return -1 endi - -if $data10 != @20-01-05 13:52:24.000@ then +if $data10 != @20-01-05 13:51:24.000@ then return -1 endi - -if $data11 != 1 then +if $data11 != 0 then return -1 endi - -if $data90 != @20-01-05 14:00:24.000@ then +print $data90 $data91 +if $data90 != @20-01-05 13:55:24.000@ then return -1 endi - -if $data91 != 9 then +if $data91 != 4 then return -1 endi # different sort order # super table & normal table mixed up -sql select c3 from union_tb0 limit 2 union all select sum(c1) as c3 from union_mt0; +sql (select c3 from union_tb0 limit 2) union all (select sum(c1) as c3 from union_mt0) order by c3; if $rows != 3 then return -1 endi - if $data00 != 0 then return -1 endi - if $data10 != 1 then return -1 endi - if $data20 != 4950000 then return -1 endi # type compatible -sql select c3 from union_tb0 limit 2 union all select sum(c1) as c3 from union_tb1; +sql (select c3 from union_tb0 limit 2) union all (select sum(c1) as c3 from union_tb1) order by c3; if $rows != 3 then return -1 endi - if $data00 != 0 then return -1 endi - if $data10 != 1 then return -1 endi - if $data20 != 495000 then return -1 endi # two join subclause -sql select count(*) as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts union all select union_tb0.c3 as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts limit 10 +sql (select count(*) as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts) union all (select union_tb0.c3 as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1.ts limit 10) order by c desc if $rows != 11 then return -1 endi - if $data00 != 10000 then return -1 endi - -if $data10 != 0 then +if $data10 != 9 then return -1 endi - -if $data20 != 1 then +if $data20 != 8 then return -1 endi - -if $data90 != 8 then +if $data90 != 1 then return -1 endi print ===========================================tags union # two super table tag union, limit is not active during retrieve tags query -sql select t1 from union_mt0 union all select t1 from union_mt0 -if $rows != 20 then - return -1 -endi - -if $data00 != 0 then - return -1 -endi - -if $data90 != 9 then +sql (select t1 from union_mt0) union all (select t1 from union_mt0) +if $rows != 200000 then return -1 endi @@ -271,39 +240,35 @@ endi #endi #========================================== two super table join subclause print ================two super table join subclause -sql select avg(union_mt0.c1) as c from union_mt0 interval(1h) limit 10 union all select union_mt1.ts, union_mt1.c1/1.0 as c from union_mt0, union_mt1 where union_mt1.ts=union_mt0.ts and union_mt1.t1=union_mt0.t1 limit 5; +sql (select _wstart as ts, avg(union_mt0.c1) as c from union_mt0 interval(1h) limit 10) union all (select union_mt1.ts, union_mt1.c1/1.0 as c from union_mt0, union_mt1 where union_mt1.ts=union_mt0.ts and union_mt1.t1=union_mt0.t1 limit 5); print the rows value is: $rows - if $rows != 15 then return -1 endi # first subclause are empty -sql select count(*) as c from union_tb0 where ts > now + 3650d union all select sum(c1) as c from union_tb1; +sql (select count(*) as c from union_tb0 where ts > now + 3650d) union all (select sum(c1) as c from union_tb1); if $rows != 1 then return -1 endi - if $data00 != 495000 then return -1 endi # all subclause are empty -sql select c1 from union_tb0 limit 0 union all select c1 from union_tb1 where ts>'2021-1-1 0:0:0' +sql (select c1 from union_tb0 limit 0) union all (select c1 from union_tb1 where ts>'2021-1-1 0:0:0') if $rows != 0 then return -1 endi # middle subclause empty -sql select c1 from union_tb0 limit 1 union all select c1 from union_tb1 where ts>'2030-1-1 0:0:0' union all select last(c1) as c1 from union_tb1; +sql (select c1 from union_tb0 limit 1) union all (select c1 from union_tb1 where ts>'2030-1-1 0:0:0' union all select last(c1) as c1 from union_tb1) order by c1; if $rows != 2 then return -1 endi - if $data00 != 0 then return -1 endi - if $data10 != 99 then return -1 endi @@ -319,141 +284,90 @@ sql (select ts, c1 from union_mt0 limit 1) union all (select ts, c1 from union_m if $rows != 2 then return -1 endi - if $data00 != @20-01-05 13:51:24.000@ then return -1 endi - if $data01 != 0 then return -1 endi - if $data10 != @20-01-05 13:51:24.000@ then return -1 endi - if $data11 != 0 then return -1 endi # two aggregated functions for super tables -sql select sum(c1) as a from union_mt0 interval(1s) limit 9 union all select ts, max(c3) as a from union_mt0 limit 2; +sql (select _wstart as ts, sum(c1) as a from union_mt0 interval(1s) limit 9) union all (select ts, max(c3) as a from union_mt0 limit 2) order by ts; if $rows != 10 then return -1 endi - if $data00 != @20-01-05 13:51:24.000@ then return -1 endi - if $data01 != 0 then return -1 endi - if $data10 != @20-01-05 13:52:24.000@ then return -1 endi - if $data11 != 10 then return -1 endi - if $data20 != @20-01-05 13:53:24.000@ then return -1 endi - if $data21 != 20 then return -1 endi - if $data90 != @20-01-05 15:30:24.000@ then return -1 endi - if $data91 != 99 then return -1 endi #================================================================================================= # two aggregated functions for normal tables -sql select sum(c1) as a from union_tb0 limit 1 union all select sum(c3) as a from union_tb1 limit 2; +sql (select sum(c1) as a from union_tb0 limit 1) union all (select sum(c3) as a from union_tb1 limit 2); if $rows != 2 then return -1 endi - if $data00 != 495000 then return -1 endi - if $data10 != 495000 then return -1 endi # two super table query + interval + limit -sql select ts, first(c3) as a from union_mt0 limit 1 union all select sum(c3) as a from union_mt0 interval(1h) limit 1; +sql (select ts, first(c3) as a from union_mt0 limit 1) union all (select _wstart as ts, sum(c3) as a from union_mt0 interval(1h) limit 1) order by ts desc; if $rows != 2 then return -1 endi - if $data00 != @20-01-05 13:51:24.000@ then return -1 endi - if $data01 != 0 then return -1 endi - if $data10 != @20-01-05 13:00:00.000@ then return -1 endi - if $data11 != 360 then return -1 endi -sql select server_status() union all select server_status() -if $rows != 2 then - return -1 -endi - -if $data00 != 1 then - return -1 -endi - -if $data10 != 1 then - return -1 -endi - -sql select client_version() union all select server_version() -if $rows != 2 then - return -1 -endi - -sql select database() union all select database() -if $rows != 2 then - return -1 -endi - -if $data00 != @union_db0@ then - return -1 -endi - -if $data10 != @union_db0@ then - return -1 -endi - -sql select 'aaa' as option from union_tb1 where c1 < 0 limit 1 union all select 'bbb' as option from union_tb0 limit 1 +sql (select 'aaa' as option from union_tb1 where c1 < 0 limit 1) union all (select 'bbb' as option from union_tb0 limit 1) if $rows != 1 then return -1 endi - if $data00 != @bbb@ then return -1 endi - -sql_error show tables union all show tables -sql_error show stables union all show stables -sql_error show databases union all show databases +sql_error (show tables) union all (show tables) +sql_error (show stables) union all (show stables) +sql_error (show databases) union all (show databases) system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/union_sysinfo.sim b/tests/script/tsim/parser/union_sysinfo.sim new file mode 100644 index 0000000000000000000000000000000000000000..ea45dc68e118e01ea054c30ae265eb791e9d5ec4 --- /dev/null +++ b/tests/script/tsim/parser/union_sysinfo.sim @@ -0,0 +1,35 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql (select server_status()) union all (select server_status()) +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +sql (select client_version()) union all (select server_version()) +if $rows != 2 then + return -1 +endi + +sql (select database()) union all (select database()) +if $rows != 2 then + return -1 +endi +if $data00 != @union_db0@ then + return -1 +endi +if $data10 != @union_db0@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT