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 create table tba3 using sta tags(null, null, '');
sql create table tba4 using sta tags(1, false, null);
sql create table tba5 using sta tags(3, true, 'aa');
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', null, null, null);
sql insert into tba2 values ('2022-09-27 15:15:01', 0, "a", false);
sql insert into tba2 values ('2022-09-27 15:15:02', 1, "0", true);
sql insert into tba2 values ('2022-09-27 15:15:03', 5, "5", false);
sql insert into tba2 values ('2022-09-27 15:15:04', null, null, null);
sql insert into tba3 values ('2022-09-28 15:15:01', 0, "a", false);
sql insert into tba3 values ('2022-09-28 15:15:02', 1, "0", true);
sql insert into tba3 values ('2022-09-28 15:15:03', 5, "5", false);
sql insert into tba3 values ('2022-09-28 15:15:04', null, null, null);
sql insert into tba4 values ('2022-09-29 15:15:01', 0, "a", false);
sql insert into tba4 values ('2022-09-29 15:15:02', 1, "0", true);
sql insert into tba4 values ('2022-09-29 15:15:03', 5, "5", false);
sql insert into tba4 values ('2022-09-29 15:15:04', null, null, null);
sql insert into tba5 values ('2022-09-30 15:15:01', 0, "a", false);
sql insert into tba5 values ('2022-09-30 15:15:02', 1, "0", true);
sql insert into tba5 values ('2022-09-30 15:15:03', 5, "5", false);
sql insert into tba5 values ('2022-09-30 15:15:04', null, null, null);
sql select case when 3 then 4 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 4 then
return -1
endi
if $data10 != 4 then
return -1
endi
if $data20 != 4 then
return -1
endi
if $data30 != 4 then
return -1
endi
sql select case when 0 then 4 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when null then 4 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when 1 then 4+1 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 5.000000000 then
return -1
endi
if $data10 != 5.000000000 then
return -1
endi
if $data20 != 5.000000000 then
return -1
endi
if $data30 != 5.000000000 then
return -1
endi
sql select case when 1-1 then 0 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when 1+1 then 0 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data10 != 0 then
return -1
endi
if $data20 != 0 then
return -1
endi
if $data30 != 0 then
return -1
endi
sql select case when 1 then 1-1+2 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 2.000000000 then
return -1
endi
if $data10 != 2.000000000 then
return -1
endi
if $data20 != 2.000000000 then
return -1
endi
if $data30 != 2.000000000 then
return -1
endi
sql select case when 1 > 0 then 1 < 2 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 1 then
return -1
endi
if $data30 != 1 then
return -1
endi
sql select case when 1 > 2 then 1 < 2 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when abs(3) then abs(-1) end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 1 then
return -1
endi
if $data30 != 1 then
return -1
endi
sql select case when abs(1+1) then abs(-1)+abs(3) end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 4.000000000 then
return -1
endi
if $data10 != 4.000000000 then
return -1
endi
if $data20 != 4.000000000 then
return -1
endi
if $data30 != 4.000000000 then
return -1
endi
sql select case when 0 then 1 else 3 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 3 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 3 then
return -1
endi
if $data30 != 3 then
return -1
endi
sql select case when 0 then 1 when 1 then 0 else 3 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data10 != 0 then
return -1
endi
if $data20 != 0 then
return -1
endi
if $data30 != 0 then
return -1
endi
sql select case when 0 then 1 when 1 then 0 when 2 then 3 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data10 != 0 then
return -1
endi
if $data20 != 0 then
return -1
endi
if $data30 != 0 then
return -1
endi
sql select case when 'a' then 'b' when null then 0 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when '2' then 'b' when null then 0 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != b then
return -1
endi
if $data10 != b then
return -1
endi
if $data20 != b then
return -1
endi
if $data30 != b then
return -1
endi
sql select case when 0 then 'b' else null end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when 0 then 'b' else 2 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 2 then
return -1
endi
if $data20 != 2 then
return -1
endi
if $data30 != 2 then
return -1
endi
sql select case when sum(2) then sum(2)-sum(1) end from tba1;
if $rows != 1 then
return -1
endi
if $data00 != 4.000000000 then
return -1
endi
sql select case when sum(2) then abs(-2) end from tba1;
if $rows != 1 then
return -1
endi
if $data00 != 2 then
return -1
endi
sql select case when ts then ts end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != @22-09-26 15:15:01.000@ then
return -1
endi
if $data10 != @22-09-26 15:15:02.000@ then
return -1
endi
if $data20 != @22-09-26 15:15:03.000@ then
return -1
endi
if $data30 != @22-09-26 15:15:04.000@ then
return -1
endi
sql select case when f1 then ts end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != @22-09-26 15:15:02.000@ then
return -1
endi
if $data20 != @22-09-26 15:15:03.000@ then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when f1 then f1 when f1 + 1 then f1 + 1 else f1 is null end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 5 then
return -1
endi
if $data30 != 1 then
return -1
endi
sql select case when f1 then 3 when ts then ts end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 1664176501000 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 3 then
return -1
endi
if $data30 != 1664176504000 then
return -1
endi
sql select case when 3 then f1 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 5 then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when f1 then 3 when 1 then 2 end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 3 then
return -1
endi
if $data30 != 2 then
return -1
endi
sql select case when sum(f1) then sum(f1)-abs(-1) end from tba1;
if $rows != 1 then
return -1
endi
if $data00 != 5.000000000 then
return -1
endi
sql select case when sum(f1) then sum(f1)-abs(f1) end from tba1;
if $rows != 4 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != 0.000000000 then
return -1
endi
if $data20 != 0.000000000 then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case when f1 then sum(f1) when f1 is not null then 9 else 8 end from tba1 group by f1 order by f1;
if $rows != 4 then
return -1
endi
if $data00 != 8 then
return -1
endi
if $data10 != 9 then
return -1
endi
if $data20 != 1 then
return -1
endi
if $data30 != 5 then
return -1
endi
sql select f1 from tba1 where f1 > case when f1 then 0 else 3 end;
if $rows != 2 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 5 then
return -1
endi
sql select f1 from tba1 where ts > case when ts then ts end;
if $rows != 0 then
return -1
endi
sql select sum(f1),count(f1) from tba1 partition by case when f1 then f1 when 1 then 1 end;
if $rows != 2 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != 5 then
return -1
endi
if $data11 != 1 then
return -1
endi
sql select case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end caseWhen, sum(f1),count(f1) from tba1 group by case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end
order by caseWhen;
if $rows != 3 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data02 != 2 then
return -1
endi
if $data10 != 2 then
return -1
endi
if $data11 != 5 then
return -1
endi
if $data12 != 1 then
return -1
endi
if $data20 != 3 then
return -1
endi
if $data21 != NULL then
return -1
endi
if $data22 != 0 then
return -1
endi
sql select f1 from tba1 order by case when f1 <= 0 then 3 when f1 = 1 then 4 when f1 >= 3 then 2 else 1 end desc;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 0 then
return -1
endi
if $data20 != 5 then
return -1
endi
if $data30 != NULL then
return -1
endi
sql_error select case when sum(f1) then sum(f1)-abs(f1) end from tba1;