feat: add more case when cases

This commit is contained in:
dapan1121 2022-10-12 16:15:46 +08:00
parent 5e4148e1cf
commit c4401b20ba
1 changed files with 45 additions and 0 deletions

View File

@ -585,6 +585,31 @@ if $data30 != NULL then
return -1 return -1
endi endi
sql select cast(case f1 when f1 then f1 + 1 else f1 is null end as double) from tba1;
if $rows != 4 then
return -1
endi
if $data00 != 1.000000000 then
return -1
endi
if $data10 != 2.000000000 then
return -1
endi
if $data20 != 6.000000000 then
return -1
endi
if $data30 != 1.000000000 then
return -1
endi
sql select sum(case f1 when f1 then f1 + 1 else f1 is null end + 1) from tba1;
if $rows != 1 then
return -1
endi
if $data00 != 14.000000000 then
return -1
endi
sql select case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end,sum(f1),count(f1) from tba1 state_window(case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end); sql select case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end,sum(f1),count(f1) from tba1 state_window(case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end);
if $rows != 3 then if $rows != 3 then
return -1 return -1
@ -1014,6 +1039,26 @@ if $data30 != 5.000000000 then
return -1 return -1
endi endi
sql select distinct tbname, case t1 when t2 then t1 else t1 + 100 end from sta order by tbname;
if $rows != 5 then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data11 != 1 then
return -1
endi
if $data21 != NULL then
return -1
endi
if $data31 != 101 then
return -1
endi
if $data41 != 103 then
return -1
endi
sql_error select case when sum(f1) then sum(f1)-abs(f1) end from tba1; sql_error select case when sum(f1) then sum(f1)-abs(f1) end from tba1;
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT