opti:add case
This commit is contained in:
parent
d51731b32a
commit
fae8f5bfa5
|
@ -1064,9 +1064,9 @@ sql_error select case when sum(f1) then sum(f1)-abs(f1) end from tba1;
|
||||||
sql drop database if exists test_db;
|
sql drop database if exists test_db;
|
||||||
sql create database test_db vgroups 5;
|
sql create database test_db vgroups 5;
|
||||||
sql use test_db;
|
sql use test_db;
|
||||||
sql create stable test_stable (ts TIMESTAMP,c_int INT,c_uint INT UNSIGNED, c_bigint BIGINT, c_ubigint BIGINT UNSIGNED, c_float FLOAT, c_double DOUBLE, c_binary BINARY(20), c_smallint SMALLINT, c_usmallint SMALLINT UNSIGNED, c_tinyint TINYINT,c_utinyint TINYINT UNSIGNED,c_bool BOOL,c_nchar NCHAR(20), c_varchar VARCHAR(20)) tags(tag_id INT);
|
sql create stable test_stable (ts TIMESTAMP,c_int INT,c_uint INT UNSIGNED, c_bigint BIGINT, c_ubigint BIGINT UNSIGNED, c_float FLOAT, c_double DOUBLE, c_binary BINARY(20), c_smallint SMALLINT, c_usmallint SMALLINT UNSIGNED, c_tinyint TINYINT,c_utinyint TINYINT UNSIGNED,c_bool BOOL,c_nchar NCHAR(20), c_varchar VARCHAR(20), c_varbinary VARBINARY(20), c_geometry GEOMETRY(50)) tags(tag_id INT);
|
||||||
sql create table t_test using test_stable tags(1);
|
sql create table t_test using test_stable tags(1);
|
||||||
sql insert into t_test values ('2022-09-30 15:15:01',123,456,1234567890,9876543210,123.45,678.90,'binary_val',32767,65535,127,255,true,'涛思数据','varchar_val');
|
sql insert into t_test values ('2022-09-30 15:15:01',123,456,1234567890,9876543210,123.45,678.90,'binary_val',32767,65535,127,255,true,'涛思数据','varchar_val', '1101', 'point(10 10)');
|
||||||
|
|
||||||
sql select case when c_int > 100 then c_float else c_int end as result from t_test;
|
sql select case when c_int > 100 then c_float else c_int end as result from t_test;
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
@ -1088,7 +1088,6 @@ sql select case when c_bool then c_bool else c_utinyint end as result from t_tes
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
print $data00
|
|
||||||
if $data00 != 1 then
|
if $data00 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
@ -1126,4 +1125,18 @@ sql select case when c_double > 100 then c_nchar else c_double end as result fro
|
||||||
if $data00 != 0.000000000 then
|
if $data00 != 0.000000000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
||||||
|
sql select case when c_bool then c_varbinary else c_varchar end as result from t_test;
|
||||||
|
if $data00 != null then
|
||||||
|
return -1;
|
||||||
|
endi
|
||||||
|
sql select case when ts > '2022-01-01 00:00:00' then c_varchar else c_geometry end as result from t_test;
|
||||||
|
|
||||||
|
if $data00 != varchar_val then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql_error select case when c_double > 100 then c_varbinary else c_geometry end as result from t_test;
|
||||||
|
sql_error select case when ts > '2022-01-01 00:00:00' then c_bool else c_geometry end as result from t_test;
|
||||||
|
sql_error select case when c_bool then c_double else c_varbinary end as result from t_test;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,8 @@ class TDTestCase:
|
||||||
self.constant_check(database,sql1,sql2,5)
|
self.constant_check(database,sql1,sql2,5)
|
||||||
|
|
||||||
#TD-20260
|
#TD-20260
|
||||||
# sql1 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1 where tbname = 'stable_1_1' and ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database
|
sql1 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1 where tbname = 'stable_1_1' and ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database
|
||||||
# sql2 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1_1 where ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database
|
sql2 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1_1 where ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database
|
||||||
self.constant_check(database,sql1,sql2,0)
|
self.constant_check(database,sql1,sql2,0)
|
||||||
self.constant_check(database,sql1,sql2,1)
|
self.constant_check(database,sql1,sql2,1)
|
||||||
self.constant_check(database,sql1,sql2,2)
|
self.constant_check(database,sql1,sql2,2)
|
||||||
|
@ -159,7 +159,7 @@ class TDTestCase:
|
||||||
'first case when q_int < %d then %d when q_int >= %d then %d else %d end last' %(a1,a2,a1,a2,a3), #'first case when q_int < 3 then 1 when q_int >= 3 then 2 else 3 end last' ,
|
'first case when q_int < %d then %d when q_int >= %d then %d else %d end last' %(a1,a2,a1,a2,a3), #'first case when q_int < 3 then 1 when q_int >= 3 then 2 else 3 end last' ,
|
||||||
'first cast(case q_int when q_int then q_int + (%d) else q_int is null end as double) last' %(a1), #'first cast(case q_int when q_int then q_int + 1 else q_int is null end as double) last' ,
|
'first cast(case q_int when q_int then q_int + (%d) else q_int is null end as double) last' %(a1), #'first cast(case q_int when q_int then q_int + 1 else q_int is null end as double) last' ,
|
||||||
'first sum(case q_int when q_int then q_int + (%d) else q_int is null end + (%d)) last' %(a1,a2), #'first sum(case q_int when q_int then q_int + 1 else q_int is null end + 1) last' ,
|
'first sum(case q_int when q_int then q_int + (%d) else q_int is null end + (%d)) last' %(a1,a2), #'first sum(case q_int when q_int then q_int + 1 else q_int is null end + 1) last' ,
|
||||||
#'first case when q_int is not null then case when q_int <= %d then q_int else q_int * (%d) end else -(%d) end last' %(a1,a1,a3), #'first case when q_int is not null then case when q_int <= 0 then q_int else q_int * 10 end else -1 end last' ,
|
'first case when q_int is not null then case when q_int <= %d then q_int else q_int * (%d) end else -(%d) end last' %(a1,a1,a3), #'first case when q_int is not null then case when q_int <= 0 then q_int else q_int * 10 end else -1 end last' ,
|
||||||
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 3 then 4 end last' ,
|
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 3 then 4 end last' ,
|
||||||
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 1 then 4 end last' ,
|
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 1 then 4 end last' ,
|
||||||
'first case %d when %d then %d else %d end last' %(a1,a1,a2,a3), # 'first case 3 when 1 then 4 else 2 end last' ,
|
'first case %d when %d then %d else %d end last' %(a1,a1,a2,a3), # 'first case 3 when 1 then 4 else 2 end last' ,
|
||||||
|
@ -231,12 +231,12 @@ class TDTestCase:
|
||||||
'first case when \'%d\' then \'b\' when null then %d end last' %(a1,a2) , #'first case when \'2\' then \'b\' when null then 0 end last' ,
|
'first case when \'%d\' then \'b\' when null then %d end last' %(a1,a2) , #'first case when \'2\' then \'b\' when null then 0 end last' ,
|
||||||
'first case when \'%d\' then \'b\' else null end last' %(a1), #'first case when \'0\' then \'b\' else null end last',
|
'first case when \'%d\' then \'b\' else null end last' %(a1), #'first case when \'0\' then \'b\' else null end last',
|
||||||
'first case when \'%d\' then \'b\' else %d end last' %(a1,a2), #'first case when \'0\' then \'b\' else 2 end last',
|
'first case when \'%d\' then \'b\' else %d end last' %(a1,a2), #'first case when \'0\' then \'b\' else 2 end last',
|
||||||
'first case when q_int then q_int when q_int + (%d) then q_int + (%d) else q_int is null end last' %(a1,a2) , #'first case when q_int then q_int when q_int + 1 then q_int + 1 else q_int is null end last' ,
|
'first case when q_int then q_int when q_int + (%d) then cast(q_int + (%d) as int) else q_int is null end last' %(a1,a2) , #'first case when q_int then q_int when q_int + 1 then q_int + 1 else q_int is null end last' ,
|
||||||
#'first case when q_int then %d when ts then ts end last' %(a1), #'first case when q_int then 3 when ts then ts end last' ,
|
'first case when q_int then %d when ts then cast(ts as int) end last' %(a1), #'first case when q_int then 3 when ts then ts end last' ,
|
||||||
'first case when %d then q_int end last' %(a1), #'first case when 3 then q_int end last' ,
|
'first case when %d then q_int end last' %(a1), #'first case when 3 then q_int end last' ,
|
||||||
'first case when q_int then %d when %d then %d end last' %(a1,a1,a3), #'first case when q_int then 3 when 1 then 2 end last' ,
|
'first case when q_int then %d when %d then %d end last' %(a1,a1,a3), #'first case when q_int then 3 when 1 then 2 end last' ,
|
||||||
'first case when q_int < %d then %d when q_int >= %d then %d else %d end last' %(a1,a2,a1,a2,a3), #'first case when q_int < 3 then 1 when q_int >= 3 then 2 else 3 end last' ,
|
'first case when q_int < %d then %d when q_int >= %d then %d else %d end last' %(a1,a2,a1,a2,a3), #'first case when q_int < 3 then 1 when q_int >= 3 then 2 else 3 end last' ,
|
||||||
#'first case when q_int is not null then case when q_int <= %d then q_int else q_int * (%d) end else -(%d) end last' %(a1,a1,a3), #'first case when q_int is not null then case when q_int <= 0 then q_int else q_int * 10 end else -1 end last' ,
|
'first case when q_int is not null then case when q_int <= %d then q_int else cast(q_int * (%d) as int) end else -(%d) end last' %(a1,a1,a3), #'first case when q_int is not null then case when q_int <= 0 then q_int else q_int * 10 end else -1 end last' ,
|
||||||
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 3 then 4 end last' ,
|
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 3 then 4 end last' ,
|
||||||
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 1 then 4 end last' ,
|
'first case %d when %d then %d end last' %(a1,a2,a3), # 'first case 3 when 1 then 4 end last' ,
|
||||||
'first case %d when %d then %d else %d end last' %(a1,a1,a2,a3), # 'first case 3 when 1 then 4 else 2 end last' ,
|
'first case %d when %d then %d else %d end last' %(a1,a1,a2,a3), # 'first case 3 when 1 then 4 else 2 end last' ,
|
||||||
|
@ -250,15 +250,15 @@ class TDTestCase:
|
||||||
'first case when \'a\' then \'b\' when null then %d end last' %(a1), # 'first case when \'a\' then \'b\' when null then 0 end last' ,
|
'first case when \'a\' then \'b\' when null then %d end last' %(a1), # 'first case when \'a\' then \'b\' when null then 0 end last' ,
|
||||||
'first case when \'%d\' then \'b\' when null then %d end last' %(a1,a2), # 'first case when \'2\' then \'b\' when null then 0 end last' ,
|
'first case when \'%d\' then \'b\' when null then %d end last' %(a1,a2), # 'first case when \'2\' then \'b\' when null then 0 end last' ,
|
||||||
'first case when %d then \'b\' else null end last' %(a1), # 'first case when 0 then \'b\' else null end last' ,
|
'first case when %d then \'b\' else null end last' %(a1), # 'first case when 0 then \'b\' else null end last' ,
|
||||||
'first case when %d then \'b\' else %d+abs(%d) end last' %(a1,a2,a3), # 'first case when 0 then \'b\' else 2+abs(-2) end last' ,
|
'first case when %d then \'b\' else cast(%d+abs(%d) as int) end last' %(a1,a2,a3), # 'first case when 0 then \'b\' else 2+abs(-2) end last' ,
|
||||||
'first case when %d then %d end last' %(a1,a2), # 'first case when 3 then 4 end last' ,
|
'first case when %d then %d end last' %(a1,a2), # 'first case when 3 then 4 end last' ,
|
||||||
'first case when %d then %d end last' %(a1,a2), # 'first case when 0 then 4 end last' ,
|
'first case when %d then %d end last' %(a1,a2), # 'first case when 0 then 4 end last' ,
|
||||||
'first case when null then %d end last' %(a1), # 'first case when null then 4 end last' ,
|
'first case when null then %d end last' %(a1), # 'first case when null then 4 end last' ,
|
||||||
#'first case when %d then %d+(%d) end last' %(a1,a2,a3), # 'first case when 1 then 4+1 end last' ,
|
'first case when %d then cast(%d+(%d) as int) end last' %(a1,a2,a3), # 'first case when 1 then 4+1 end last' ,
|
||||||
'first case when %d-(%d) then %d end last' %(a1,a2,a3), # 'first case when 1-1 then 0 end last' ,
|
'first case when %d-(%d) then %d end last' %(a1,a2,a3), # 'first case when 1-1 then 0 end last' ,
|
||||||
'first case when %d+(%d) then %d end last' %(a1,a2,a3), # 'first case when 1+1 then 0 end last' ,
|
'first case when %d+(%d) then %d end last' %(a1,a2,a3), # 'first case when 1+1 then 0 end last' ,
|
||||||
'first case when abs(%d) then abs(%d) end last' %(a1,a2), # 'first case when abs(3) then abs(-1) end last' ,
|
'first case when abs(%d) then abs(%d) end last' %(a1,a2), # 'first case when abs(3) then abs(-1) end last' ,
|
||||||
#'first case when abs(%d+(%d)) then abs(%d)+abs(%d) end last' %(a1,a2,a3,a1), # 'first case when abs(1+1) then abs(-1)+abs(3) end last' ,
|
'first case when abs(%d+(%d)) then cast(abs(%d)+abs(%d) as int) end last' %(a1,a2,a3,a1), # 'first case when abs(1+1) then abs(-1)+abs(3) end last' ,
|
||||||
'first case when %d then %d else %d end last' %(a1,a2,a3), # 'first case when 0 then 1 else 3 end last' ,
|
'first case when %d then %d else %d end last' %(a1,a2,a3), # 'first case when 0 then 1 else 3 end last' ,
|
||||||
'first case when %d then %d when %d then %d else %d end last' %(a1,a2,a3,a1,a2), # 'first case when 0 then 1 when 1 then 0 else 3 end last' ,
|
'first case when %d then %d when %d then %d else %d end last' %(a1,a2,a3,a1,a2), # 'first case when 0 then 1 when 1 then 0 else 3 end last' ,
|
||||||
'first case when %d then %d when %d then %d when %d then %d end last' %(a1,a2,a3,a1,a2,a3), # 'first case when 0 then 1 when 1 then 0 when 2 then 3 end last' ,
|
'first case when %d then %d when %d then %d when %d then %d end last' %(a1,a2,a3,a1,a2,a3), # 'first case when 0 then 1 when 1 then 0 when 2 then 3 end last' ,
|
||||||
|
|
Loading…
Reference in New Issue