From c4401b20baccf8720a9fc1199c784d4e3d451305 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 12 Oct 2022 16:15:46 +0800 Subject: [PATCH] feat: add more case when cases --- tests/script/tsim/scalar/caseWhen.sim | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/script/tsim/scalar/caseWhen.sim b/tests/script/tsim/scalar/caseWhen.sim index f105f9b483..f6b9c3ff08 100644 --- a/tests/script/tsim/scalar/caseWhen.sim +++ b/tests/script/tsim/scalar/caseWhen.sim @@ -585,6 +585,31 @@ if $data30 != NULL then return -1 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); if $rows != 3 then return -1 @@ -1014,6 +1039,26 @@ if $data30 != 5.000000000 then return -1 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; system sh/exec.sh -n dnode1 -s stop -x SIGINT