290 lines
9.4 KiB
Plaintext
290 lines
9.4 KiB
Plaintext
system sh/stop_dnodes.sh
|
|
system sh/deploy.sh -n dnode1 -i 1
|
|
system sh/exec.sh -n dnode1 -s start
|
|
sql connect
|
|
|
|
print ======== prepare data
|
|
|
|
sql drop database if exists db1;
|
|
sql create database db1 vgroups 5;
|
|
sql use db1;
|
|
sql create stable sta (ts timestamp, f1 int, f2 binary(10), f3 bool) tags(t1 int, t2 bool, t3 binary(10));
|
|
sql create table tba1 using sta tags(0, false, '0');
|
|
sql create table tba2 using sta tags(1, true, '1');
|
|
sql insert into tba1 values ('2022-09-26 15:15:01', 0, "a", false);
|
|
sql insert into tba1 values ('2022-09-26 15:15:02', 1, "0", true);
|
|
sql insert into tba1 values ('2022-09-26 15:15:03', 5, "5", false);
|
|
sql insert into tba1 values ('2022-09-26 15:15:04', 3, 'b', false);
|
|
sql insert into tba1 values ('2022-09-26 15:15:05', 0, '1', false);
|
|
sql insert into tba1 values ('2022-09-26 15:15:06', 2, 'd', true);
|
|
sql insert into tba2 values ('2022-09-26 15:15:01', 0, "a", false);
|
|
sql insert into tba2 values ('2022-09-26 15:15:02', 1, "0", true);
|
|
sql insert into tba2 values ('2022-09-26 15:15:03', 5, "5", false);
|
|
sql insert into tba2 values ('2022-09-26 15:15:04', 3, 'b', false);
|
|
sql insert into tba2 values ('2022-09-26 15:15:05', 0, '1', false);
|
|
sql insert into tba2 values ('2022-09-26 15:15:06', 2, 'd', true);
|
|
|
|
# child table: no window
|
|
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'c';
|
|
sql select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'c';
|
|
if $rows != 0 then
|
|
return -1
|
|
endi
|
|
|
|
# child table: single row window
|
|
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f3 = false;
|
|
sql select count(*) from tba1 event_window start with f1 = 0 end with f3 = false;
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data00 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
# child table: multi rows window
|
|
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'b';
|
|
sql select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'b';
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
if $data00 != 4 then
|
|
return -1
|
|
endi
|
|
|
|
# child table: multi windows
|
|
print ====> select count(*) from tba1 event_window start with f1 >= 0 end with f3 = true;
|
|
sql select count(*) from tba1 event_window start with f1 >= 0 end with f3 = true;
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data00 != 2 then
|
|
return -1
|
|
endi
|
|
if $data10 != 4 then
|
|
return -1
|
|
endi
|
|
|
|
# super table: no window
|
|
print ====> select count(*) from sta event_window start with f1 = 0 end with f2 = 'c';
|
|
sql select count(*) from sta event_window start with f1 = 0 end with f2 = 'c';
|
|
if $rows != 0 then
|
|
return -1
|
|
endi
|
|
|
|
# super table: single row window
|
|
print ====> select count(*) from sta event_window start with f1 = 0 end with f3 = false;
|
|
sql select count(*) from sta event_window start with f1 = 0 end with f3 = false;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data00 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
# super table: multi rows window
|
|
print ====> select count(*) from sta event_window start with f1 = 0 end with f2 = 'b';
|
|
sql select count(*) from sta event_window start with f1 = 0 end with f2 = 'b';
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
if $data00 != 7 then
|
|
return -1
|
|
endi
|
|
|
|
# super table: multi windows
|
|
print ====> select count(*) from sta event_window start with f1 >= 0 end with f3 = true;
|
|
sql select count(*) from sta event_window start with f1 >= 0 end with f3 = true;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data00 != 3 then
|
|
return -1
|
|
endi
|
|
if $data10 != 1 then
|
|
return -1
|
|
endi
|
|
if $data20 != 7 then
|
|
return -1
|
|
endi
|
|
if $data30 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
# multi-child table: no window
|
|
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'c';
|
|
sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'c';
|
|
if $rows != 0 then
|
|
return -1
|
|
endi
|
|
|
|
# multi-child table: single row window
|
|
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f3 = false;
|
|
sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f3 = false;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data01 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
# multi-child table: multi rows window
|
|
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'b';
|
|
sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'b';
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data01 != 4 then
|
|
return -1
|
|
endi
|
|
if $data11 != 4 then
|
|
return -1
|
|
endi
|
|
|
|
# multi-child table: multi windows
|
|
print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 >= 0 end with f3 = true;
|
|
sql select tbname, count(*) from sta partition by tbname event_window start with f1 >= 0 end with f3 = true;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data01 != 2 then
|
|
return -1
|
|
endi
|
|
if $data11 != 4 then
|
|
return -1
|
|
endi
|
|
|
|
# where + partition by
|
|
print ====> select tbname, count(*) from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0;
|
|
sql select tbname, count(*) from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data01 != 1 then
|
|
return -1
|
|
endi
|
|
if $data11 != 2 then
|
|
return -1
|
|
endi
|
|
|
|
# where + order by
|
|
print ====> select count(*) cnt from tba1 where f3 = false event_window start with f1 >0 end with f2 > 0 order by cnt desc;
|
|
sql select count(*) cnt from tba1 where f3 = false event_window start with f1 >0 end with f2 > 0 order by cnt desc;
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data00 != 2 then
|
|
return -1
|
|
endi
|
|
if $data10 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
# where + partition by + order by
|
|
print ====> select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt;
|
|
sql select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data01 != 1 then
|
|
return -1
|
|
endi
|
|
if $data11 != 1 then
|
|
return -1
|
|
endi
|
|
|
|
# where + partition by + order by + limit
|
|
print ====> select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
|
|
sql select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data01 != 2 then
|
|
return -1
|
|
endi
|
|
if $data11 != 2 then
|
|
return -1
|
|
endi
|
|
|
|
# subquery(where + partition by + order by + limit)
|
|
print ====> select * from (select tbname tname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2);
|
|
sql select * from (select tbname tname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2);
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data01 != 2 then
|
|
return -1
|
|
endi
|
|
if $data11 != 2 then
|
|
return -1
|
|
endi
|
|
|
|
# subquery + where + partition by + order by + limit
|
|
print ====> select tname, count(*) cnt from (select tbname tname, * from sta) where f3 = false partition by tname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
|
|
sql select tname, count(*) cnt from (select tbname tname, * from sta) where f3 = false partition by tname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
|
|
if $rows != 2 then
|
|
return -1
|
|
endi
|
|
if $data01 != 2 then
|
|
return -1
|
|
endi
|
|
if $data11 != 2 then
|
|
return -1
|
|
endi
|
|
|
|
sql_error select f1, f2 from sta event_window start with f1 >0 end with f2 > 0;
|
|
sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 partition by tbname;
|
|
sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 group by tbname;
|
|
sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 fill(NULL);
|
|
|
|
print step2
|
|
print =============== create database
|
|
sql create database test2 vgroups 4;
|
|
sql use test2;
|
|
sql create stable st(ts timestamp,a int,b int,c int, d double) 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 table t3 using st tags(3,3,3);
|
|
|
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
|
sql insert into t1 values(1648791223001,2,2,3,1.1);
|
|
sql insert into t1 values(1648791233002,3,2,3,2.1);
|
|
sql insert into t1 values(1648791243003,4,2,3,3.1);
|
|
sql insert into t1 values(1648791253004,5,2,3,4.1);
|
|
|
|
sql insert into t2 values(1648791213000,1,2,3,1.0);
|
|
sql insert into t2 values(1648791223001,2,2,3,1.1);
|
|
sql insert into t2 values(1648791233002,3,2,3,2.1);
|
|
sql insert into t2 values(1648791243003,4,2,3,3.1);
|
|
sql insert into t2 values(1648791253004,5,2,3,4.1);
|
|
|
|
sql insert into t3 values(1648791213000,1,2,3,1.0);
|
|
sql insert into t3 values(1648791223001,2,2,3,1.1);
|
|
sql insert into t3 values(1648791233002,3,2,3,2.1);
|
|
sql insert into t3 values(1648791243003,4,2,3,3.1);
|
|
sql insert into t3 values(1648791253004,5,2,3,4.1);
|
|
|
|
$loop_count = 0
|
|
loop4:
|
|
|
|
sleep 300
|
|
|
|
sql select _wstart, count(*) c1, tbname from st partition by tbname event_window start with a > 0 end with b = 2 slimit 2 limit 2;
|
|
|
|
print $data00 $data01 $data02 $data03
|
|
print $data10 $data11 $data12 $data13
|
|
print $data20 $data21 $data22 $data23
|
|
print $data30 $data31 $data32 $data33
|
|
|
|
$loop_count = $loop_count + 1
|
|
if $loop_count == 10 then
|
|
return -1
|
|
endi
|
|
|
|
# row 0
|
|
if $rows != 4 then
|
|
print ======rows=$rows
|
|
goto loop4
|
|
endi
|
|
|
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|