tdSql.query("select count(*) from %s.stable_1;"%database)
tdSql.checkData(0,0,num_random*n)
tdSql.query("select count(*) from %s.table_0;"%database)
tdSql.checkData(0,0,n)
defusers_bug(self,database):
sql1="select (case when `q_smallint` >0 then 'many--' when `q_smallint`<0 then 'little' end),q_int,loc from %s.stable_1 where tbname = 'stable_1_1' limit 100;"%database
sql2="select (case when `q_smallint` >0 then 'many--' when `q_smallint`<0 then 'little' end),q_int,loc from %s.stable_1_1 limit 100;"%database
self.constant_check(database,sql1,sql2,0)
sql1="select (case when `q_smallint` >0 then 'many![;;][][]]' when `q_smallint`<0 then 'little' end),q_int,loc from %s.stable_1 where tbname = 'stable_1_1' limit 100;"%database
sql2="select (case when `q_smallint` >0 then 'many![;;][][]]' when `q_smallint`<0 then 'little' end),q_int,loc from %s.stable_1_1 limit 100;"%database
self.constant_check(database,sql1,sql2,0)
sql1="select (case when sum(q_smallint)=0 then null else sum(q_smallint) end) from %s.stable_1 where tbname = 'stable_1_1' limit 100;"%database
sql2="select (case when sum(q_smallint)=0 then null else sum(q_smallint) end) from %s.stable_1_1 limit 100;"%database
self.constant_check(database,sql1,sql2,0)
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
casewhen_lists=['first case when %d then %d end last'%(a1,a2),#'first case when 3 then 4 end last' ,
'first case when 0 then %d end last'%(a1),#'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 1 then %d+(%d) end last'%(a1,a2),#'first case when 1 then 4+1 end last' ,
'first case when %d-(%d) then 0 end last'%(a1,a1),#'first case when 1-1 then 0 end last' ,
'first case when %d+(%d) then 0 end last'%(a1,a1),#'first case when 1+1 then 0 end last' ,
'first case when 1 then %d-(%d)+(%d) end last'%(a1,a1,a2),#'first case when 1 then 1-1+2 end last' ,
'first case when %d > 0 then %d < %d end last'%(a1,a1,a2),#'first case when 1 > 0 then 1 < 2 end last' ,
'first case when %d > %d then %d < %d end last'%(a1,a2,a1,a2),#'first case when 1 > 2 then 1 < 2 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,a1,a2),#'first case when abs(1+1) then abs(-1)+abs(3) end last' ,
'first case when 0 then %d else %d end last'%(a1,a2),#'first case when 0 then 1 else 3 end last' ,
'first case when 0 then %d when 1 then %d else %d end last'%(a1,a1,a3),#'first case when 0 then 1 when 1 then 0 else 3 end last' ,
'first case when 0 then %d when 1 then %d when 2 then %d end last'%(a1,a1,a3),#'first case when 0 then 1 when 1 then 0 when 2 then 3 end last' ,
'first case when \'a\' then \'b\' when null then 0 end last',#'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\' 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 sum(%d) then sum(%d)-sum(%d) end last'%(a1,a1,a3),#'first case when sum(2) then sum(2)-sum(1) end last' ,
'first case when sum(%d) then abs(-(%d)) end last'%(a1,a2),#'first case when sum(2) then abs(-2) end last' ,
'first case when q_int then ts 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 %d when ts then ts 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 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 sum(q_int) then sum(q_int)-abs(-(%d)) end last'%(a1),#'first case when sum(q_int) then sum(q_int)-abs(-1) 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 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 %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 else %d end last'%(a1,a1,a2,a3),# 'first case 3 when 1 then 4 else 2 end last' ,
'first case %d when null then %d when \'%d\' then %d end last'%(a1,a1,a2,a3),# 'first case 3 when null then 4 when \'3\' then 1 end last' ,
'first case \'%d\' when null then %d when %d then %d end last'%(a1,a1,a2,a3),# 'first case \'3\' when null then 4 when 3 then 1 end last' ,
'first case null when null then %d when %d then %d end last'%(a1,a2,a3),# 'first case null when null then 4 when 3 then 1 end last' ,
'first case %d.0 when null then %d when \'%d\' then %d end last'%(a1,a1,a2,a3),# 'first case 3.0 when null then 4 when \'3\' then 1 end last' ,
'first case q_double when \'a\' then %d when \'%d\' then %d end last'%(a1,a2,a3),# 'first case q_double when \'a\' then 4 when \'0\' then 1 end last' ,
'first case q_double when q_int then q_int when q_int - (%d) then q_int else %d end last'%(a1,a2),# 'first case q_double when q_int then q_int when q_int - 1 then q_int else 99 end last' ,
'first case cast(q_double as int) when %d then q_double when q_int then %d else ts end last'%(a1,a2),#'first case cast(q_double as int) when 0 then q_double when q_int then 11 else ts end last' ,
'first case q_int + (%d) when %d then %d when %d then %d else %d end last'%(a1,a2,a3,a1,a2,a3),#'first case q_int + 1 when 1 then 1 when 2 then 2 else 3 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\' 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 %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 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-(%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+(%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 %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 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 %d when %d then %d end last'%(a1,a1,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 else %d end last'%(a1,a2,a3,a1),# 'first case 3 when 1 then 4 else 2 end last' ,
'first case %d when null then %d when \'%d\' then %d end last'%(a1,a2,a1,a3),# 'first case 3 when null then 4 when \'3\' then 1 end last' ,
'first case null when null then %d when %d then %d end last'%(a1,a2,a3),# 'first case null when null then 4 when 3 then 1 end last' ,
'first case %d.0 when null then %d when \'%d\' then %d end last'%(a1,a2,a1,a3),# 'first case 3.0 when null then 4 when \'3\' then 1 end last' ,
'first q_double,case q_double when \'a\' then %d when \'%d\' then %d end last'%(a1,a2,a3),#'first q_double,case q_double when \'a\' then 4 when \'0\' then 1 end last' ,
'first case null when null then %d when %d then %d end last'%(a1,a2,a3),#'first case null when null then 4 when 3 then 1 end last' ,
'first q_double,q_int,case q_double when q_int then q_int when q_int - (%d ) then q_int else %d end last'%(a1,a2),# 'first q_double,q_int,case q_double when q_int then q_int when q_int - 1 then q_int else 99 end last' ,
'first case cast(q_double as int) when %d then q_double when q_int then %d else ts end last'%(a1,a2),# 'first case cast(q_double as int) when 0 then q_double when q_int then 11 else ts end last' ,
'first q_int, case q_int + (%d) when %d then %d when %d then %d else %d end last'%(a1,a1,a1,a2,a2,a3),#'first q_int, case q_int + 1 when 1 then 1 when 2 then 2 else 3 end last' ,
'first distinct loc, case t_int when t_bigint then t_ts else t_smallint + (%d) end last'%(a1),#'first distinct loc, case t_int when t_bigint then t_ts else t_smallint + 100 end last' ,
state_window_lists=['first case when %d then %d end last'%(a1,a2),#'first case when 3 then 4 end last' ,
'first case when 0 then %d end last'%(a1),#'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 %d-(%d) then 0 end last'%(a1,a1),#'first case when 1-1 then 0 end last' ,
'first case when %d+(%d) then 0 end last'%(a1,a1),#'first case when 1+1 then 0 end last' ,
'first case when %d > 0 then %d < %d end last'%(a1,a1,a2),#'first case when 1 > 0 then 1 < 2 end last' ,
'first case when %d > %d then %d < %d end last'%(a1,a2,a1,a2),#'first case when 1 > 2 then 1 < 2 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 0 then %d else %d end last'%(a1,a2),#'first case when 0 then 1 else 3 end last' ,
'first case when 0 then %d when 1 then %d else %d end last'%(a1,a1,a3),#'first case when 0 then 1 when 1 then 0 else 3 end last' ,
'first case when 0 then %d when 1 then %d when 2 then %d end last'%(a1,a1,a3),#'first case when 0 then 1 when 1 then 0 when 2 then 3 end last' ,
'first case when \'a\' then \'b\' when null then 0 end last',#'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\' 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 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 %d when ts then ts 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 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 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 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 null then %d when \'%d\' then %d end last'%(a1,a1,a2,a3),# 'first case 3 when null then 4 when \'3\' then 1 end last' ,
'first case \'%d\' when null then %d when %d then %d end last'%(a1,a1,a2,a3),# 'first case \'3\' when null then 4 when 3 then 1 end last' ,
'first case null when null then %d when %d then %d end last'%(a1,a2,a3),# 'first case null when null then 4 when 3 then 1 end last' ,
'first case %d.0 when null then %d when \'%d\' then %d end last'%(a1,a1,a2,a3),# 'first case 3.0 when null then 4 when \'3\' then 1 end last' ,
'first case q_double when \'a\' then %d when \'%d\' then %d end last'%(a1,a2,a3),# 'first case q_double when \'a\' then 4 when \'0\' then 1 end last' ,
'first case q_double when q_int then q_int when q_int - (%d) then q_int else %d end last'%(a1,a2),# 'first case q_double when q_int then q_int when q_int - 1 then q_int else 99 end last' ,
'first case q_int + (%d) when %d then %d when %d then %d else %d end last'%(a1,a2,a3,a1,a2,a3),#'first case q_int + 1 when 1 then 1 when 2 then 2 else 3 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\' 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 %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 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-(%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+(%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 %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 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 %d when %d then %d end last'%(a1,a1,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 else %d end last'%(a1,a2,a3,a1),# 'first case 3 when 1 then 4 else 2 end last' ,
'first case %d when null then %d when \'%d\' then %d end last'%(a1,a2,a1,a3),# 'first case 3 when null then 4 when \'3\' then 1 end last' ,
'first case null when null then %d when %d then %d end last'%(a1,a2,a3),# 'first case null when null then 4 when 3 then 1 end last' ,
'first case %d.0 when null then %d when \'%d\' then %d end last'%(a1,a2,a1,a3),# 'first case 3.0 when null then 4 when \'3\' then 1 end last' ,
'first case null when null then %d when %d then %d end last'%(a1,a2,a3),#'first case null when null then 4 when 3 then 1 end last' ,
'first q_int, case q_int + (%d) when %d then %d when %d then %d else %d end last'%(a1,a1,a1,a2,a2,a3),#'first q_int, case q_int + 1 when 1 then 1 when 2 then 2 else 3 end last' ,