94 lines
2.2 KiB
Plaintext
94 lines
2.2 KiB
Plaintext
sql connect
|
|
sql use testa;
|
|
|
|
sql create view view1 as select * from sta1;
|
|
sql select * from view1 order by ts;
|
|
if $rows != 4 then
|
|
return -1
|
|
endi
|
|
if $data00 != @23-10-16 09:10:11.000@ then
|
|
return -1
|
|
endi
|
|
if $data01 != 100111 then
|
|
return -1
|
|
endi
|
|
|
|
sql create or replace view view1 as select 1, 2;
|
|
sql select * from view1;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
if $data00 != 1 then
|
|
return -1
|
|
endi
|
|
if $data01 != 2 then
|
|
return -1
|
|
endi
|
|
|
|
sql create or replace view view1 as select tbname as a, f from sta1;
|
|
sql select cast(avg(f) as int) b from view1 group by a having avg(f) > 100111 order by b;
|
|
if $rows != 3 then
|
|
return -1
|
|
endi
|
|
if $data00 != 100112 then
|
|
return -1
|
|
endi
|
|
if $data10 != 100113 then
|
|
return -1
|
|
endi
|
|
if $data20 != 100114 then
|
|
return -1
|
|
endi
|
|
|
|
#sql create or replace view view1 as select tbname, avg(f) from sta1 partition by tbname;
|
|
#sql select * from view1 partition by view1.tbname;
|
|
|
|
sql create or replace view view1 as select * from sta1;
|
|
sql create or replace view testb.view2 as select * from testb.stb1;
|
|
sql_error select avg(t1.f), avg(t2.f) from view1 t1, view2 t2 where t1.ts = t2.ts and t1.f < 100114;
|
|
sql select avg(t1.f), avg(t2.f) from view1 t1, testb.view2 t2 where t1.ts = t2.ts and t1.f < 100114;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
if $data00 != 100112.000000000 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
if $data01 != 110112.000000000 then
|
|
return -1
|
|
endi
|
|
|
|
sql drop view testb.view2;
|
|
sql create or replace view view2 as select * from sta2;
|
|
sql select avg(view1.f), avg(view2.f) from view1, view2 where view1.ts = view2.ts and view1.f < 100114;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
if $data00 != 100112.000000000 then
|
|
print $data00
|
|
return -1
|
|
endi
|
|
if $data01 != 100222.000000000 then
|
|
return -1
|
|
endi
|
|
|
|
sql drop view view1;
|
|
sql drop view view2;
|
|
|
|
sql use information_schema;
|
|
sql create view view1 as select * from ins_views;
|
|
sql select * from view1;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
sql drop view view1;
|
|
sql use testa;
|
|
sql create view information_schema.view1 as select * from information_schema.ins_views;
|
|
sql select * from information_schema.view1;
|
|
if $rows != 1 then
|
|
return -1
|
|
endi
|
|
sql drop view information_schema.view1;
|
|
|
|
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|