370 lines
8.3 KiB
Plaintext
370 lines
8.3 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
|
|
|
|
sql drop database if exists db1;
|
|
sql create database if not exists db1 cachemodel 'both' cachesize 10;
|
|
sql use db1;
|
|
sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 int);
|
|
sql create table tba1 using sta tags(1);
|
|
sql insert into tba1 values ('2022-04-26 15:15:01', 1.0, "a");
|
|
sql insert into tba1 values ('2022-04-26 15:15:02', 2.0, "b");
|
|
sql insert into tba1 values ('2022-04-26 15:15:04', 4.0, "b");
|
|
sql insert into tba1 values ('2022-04-26 15:15:05', 5.0, "b");
|
|
sql create table tba2 using sta tags(2);
|
|
sql insert into tba2 values ('2022-04-26 15:15:01', 1.2, "a");
|
|
sql insert into tba2 values ('2022-04-26 15:15:02', 2.2, "b");
|
|
sql create table tba3 using sta tags(3);
|
|
sql insert into tba3 values ('2022-04-26 15:15:10', 1.3, "a");
|
|
sql insert into tba3 values ('2022-04-26 15:15:11', 2.3, "b");
|
|
sql select count(*), last(*) from sta;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
if $data00 != 8 then
|
|
return -1
|
|
endi
|
|
if $data01 != @22-04-26 15:15:11.000@ then
|
|
return -1
|
|
endi
|
|
if $data02 != 2.300000000 then
|
|
return -1
|
|
endi
|
|
if $data03 != b then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last(*) from sta;
|
|
if $data00 != @-> Merge (columns=4 width=226 input_order=unknown output_order=unknown mode=column)@ then
|
|
return -1
|
|
endi
|
|
sql explain select first(f1), last(*) from sta;
|
|
if $data00 != @-> Merge (columns=4 width=226 input_order=unknown output_order=unknown mode=column)@ then
|
|
return -1
|
|
endi
|
|
sql select first(f1), last(*) from sta;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
sql select last_row(f1), last(f1) from sta;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
sql select count(*), last_row(f1), last(f1) from sta;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), last(f1) from sta;
|
|
if $data00 != @-> Merge (columns=3 width=24 input_order=unknown output_order=unknown mode=column)@ then
|
|
return -1
|
|
endi
|
|
sql_error select count(*), last_row(f1), min(f1), f1 from sta;
|
|
sql select count(*), last_row(f1), min(f1),tbname from sta partition by tbname;
|
|
if $rows != 3 then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), min(f1),tbname from sta partition by tbname;
|
|
if $data00 != @-> Data Exchange 2:1 (width=296)@ then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), min(f1) from sta;
|
|
if $data00 != @-> Merge (columns=3 width=24 input_order=unknown output_order=unknown mode=column)@ then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), min(f1),tbname from sta group by tbname;
|
|
if $data00 != @-> Data Exchange 2:1 (width=296)@ then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), min(f1),t1 from sta partition by t1;
|
|
if $data00 != @-> Aggregate (functions=4 width=28 input_order=desc )@ then
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), min(f1),t1 from sta group by t1;
|
|
if $data00 != @-> Aggregate (functions=4 width=28 input_order=desc )@ then
|
|
return -1
|
|
endi
|
|
sql explain select distinct count(*), last_row(f1), min(f1) from sta;
|
|
if $data10 != @ -> Merge (columns=3 width=24 input_order=unknown output_order=unknown mode=column)@ then
|
|
print $data10
|
|
return -1
|
|
endi
|
|
sql explain select count(*), last_row(f1), min(f1) from sta interval(1s);
|
|
if $data10 != @ -> Merge (columns=4 width=106 input_order=asc output_order=asc mode=sort)@ then
|
|
return -1
|
|
endi
|
|
sql explain select distinct count(*), last_row(f1), min(f1) from tba1;
|
|
if $data10 != @ -> Merge (columns=3 width=24 input_order=unknown output_order=unknown mode=column)@ then
|
|
return -1
|
|
endi
|
|
sql select distinct count(*), last_row(f1), min(f1) from tba1;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
|
|
print step 2-------------------------------
|
|
|
|
sql drop database if exists test;
|
|
sql create database test cachemodel 'both';
|
|
sql use test;
|
|
sql create table stb (ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
|
|
|
|
sql create table t1 using stb tags(1,1,1);
|
|
sql create table t2 using stb tags(2,2,2);
|
|
sql insert into t1 values('2024-06-05 11:00:00',1,2,3);
|
|
sql insert into t1 values('2024-06-05 12:00:00',2,2,3);
|
|
sql insert into t2 values('2024-06-05 13:00:00',3,2,3);
|
|
sql insert into t2 values('2024-06-05 14:00:00',4,2,3);
|
|
|
|
sql select last(ts) ts1,ts from stb;
|
|
|
|
if $data00 != $data01 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,ts from stb group by tbname;
|
|
|
|
if $data00 != $data01 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,tbname, ts from stb;
|
|
|
|
if $data00 != $data02 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != t2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,tbname, ts from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != $data02 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != t2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
print step 3-------------------------------
|
|
|
|
sql drop database if exists test1;
|
|
sql create database test1 cachemodel 'both' vgroups 4;
|
|
sql use test1;
|
|
sql create table stb (ts timestamp,a int primary key,b int,c int) tags(ta int,tb int,tc int);
|
|
|
|
sql create table aaat1 using stb tags(1,1,1);
|
|
sql create table bbbt2 using stb tags(2,2,2);
|
|
sql insert into aaat1 values('2024-06-05 11:00:00',1,2,3);
|
|
sql insert into aaat1 values('2024-06-05 12:00:00',2,2,3);
|
|
sql insert into bbbt2 values('2024-06-05 13:00:00',3,2,3);
|
|
sql insert into bbbt2 values('2024-06-05 14:00:00',4,2,3);
|
|
|
|
sql select last(ts) ts1,ts from stb;
|
|
|
|
if $data00 != $data01 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,ts from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != $data01 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,tbname, ts from stb;
|
|
|
|
if $data00 != $data02 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != bbbt2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,tbname, ts from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != $data02 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != bbbt2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
print step 4-------------------------------
|
|
|
|
sql select last(a) a,ts from stb;
|
|
|
|
if $data00 != 4 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != @24-06-05 14:00:00.000@ then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
sql select last(a) a,ts from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != 4 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != @24-06-05 14:00:00.000@ then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
sql select last(a) a,tbname, ts from stb;
|
|
|
|
if $data00 != 4 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != bbbt2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
if $data02 != @24-06-05 14:00:00.000@ then
|
|
print $data02
|
|
return -1
|
|
endi
|
|
|
|
sql select last(a) a,tbname, ts from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != 4 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != bbbt2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
if $data02 != @24-06-05 14:00:00.000@ then
|
|
print $data02
|
|
return -1
|
|
endi
|
|
|
|
print step 5-------------------------------
|
|
|
|
sql select last(ts) ts1,a from stb;
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != 4 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,a from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != 4 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,tbname, a from stb;
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != bbbt2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
if $data02 != 4 then
|
|
print $data02
|
|
return -1
|
|
endi
|
|
|
|
sql select last(ts) ts1,tbname, a from stb group by tbname order by 1 desc;
|
|
|
|
if $data00 != @24-06-05 14:00:00.000@ then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
|
|
if $data01 != bbbt2 then
|
|
print $data01
|
|
return -1
|
|
endi
|
|
|
|
if $data02 != 4 then
|
|
print $data02
|
|
return -1
|
|
endi
|
|
|
|
$loop_count = 0
|
|
|
|
loop0:
|
|
|
|
sql select last(ts), last_row(ts) from stb;
|
|
|
|
if $data00 != $data01 then
|
|
print ====data00=$data00
|
|
print ====data01=$data01
|
|
return -1
|
|
endi
|
|
|
|
$loop_count = $loop_count + 1
|
|
if $loop_count < 10 then
|
|
sleep 200
|
|
print ====checktimes=$loop_count
|
|
goto loop0
|
|
endi
|
|
|
|
print ------------------------end
|
|
|
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|