tdSql.execute("create stable if not exists stb (ts timestamp, dataInt int, dataDouble double,dataStr nchar(200)) tags(loc nchar(50),t1 int)")
tdSql.execute("create table tb1 using stb tags('beijing1', 10)")
tdSql.execute("insert into tb1 values(1614218412000,8635,98.861,'qazwsxedcrfvtgbyhnujmikolp1')(1614218422000,8636,98.862,'qazwsxedcrfvtgbyhnujmikolp2')")
tdSql.execute("create table tb2 using stb tags('beijing2', 11)")
tdSql.execute("insert into tb2 values(1614218432000,8647,98.863,'qazwsxedcrfvtgbyhnujmikolp3')")
tdSql.execute("insert into tb2 values(1614218442000,8648,98.864,'qazwsxedcrfvtgbyhnujmikolp4')")
q_where=['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807','q_int <= 2147483647 and q_int >= -2147483647',
'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -100000 and q_float <= 100000',
'q_double >= -1000000000 and q_double <= 1000000000','q_binary like \'binary%\' or q_binary = \'0\' ','q_nchar like \'nchar%\' or q_nchar = \'0\' ',
'q_bool = true or q_bool = false','q_bool in (0 , 1)','q_bool in ( true , false)','q_bool = 0 or q_bool = 1',
'q_bigint between -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767',
'q_tinyint between -127 and 127 ','q_float between -100000 and 100000','q_double between -1000000000 and 1000000000']
#TD-6201 ,'q_bool between 0 and 1'
# regular column where for test union,join
q_u_where=['t1.ts < now +1s','t2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807',
't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647',
't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767',
't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127',
't1.q_float >= -100000 and t1.q_float <= 100000 and t2.q_float >= -100000 and t2.q_float <= 100000',
't1.q_double >= -1000000000 and t1.q_double <= 1000000000 and t2.q_double >= -1000000000 and t2.q_double <= 1000000000',
't1.q_binary like \'binary%\' and t2.q_binary like \'binary%\' ',
't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ',
't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)','t1.q_bool in ( true , false) and t2.q_bool in ( true , false)',
't1.q_bigint between -9223372036854775807 and 9223372036854775807 and t2.q_bigint between -9223372036854775807 and 9223372036854775807',
't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647',
't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767',
't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -100000 and 100000 and t2.q_float between -100000 and 100000',
't1.q_double between -1000000000 and 1000000000 and t2.q_double between -1000000000 and 1000000000']
#TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1']
#'t1.q_bool = true and t1.q_bool = false and t2.q_bool = true and t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' ,
q_u_or_where=['t1.q_binary like \'binary%\' or t1.q_binary = \'0\' or t2.q_binary like \'binary%\' or t2.q_binary = \'0\' ',
't1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' ','t1.q_bool = true or t1.q_bool = false or t2.q_bool = true or t2.q_bool = false',
't1.q_bool in (0 , 1) or t2.q_bool in (0 , 1)','t1.q_bool in ( true , false) or t2.q_bool in ( true , false)','t1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1',
't1.q_bigint between -9223372036854775807 and 9223372036854775807 or t2.q_bigint between -9223372036854775807 and 9223372036854775807',
't1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647',
't1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767',
't1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 ','t1.q_float between -100000 and 100000 or t2.q_float between -100000 and 100000',
't1.q_double between -1000000000 and 1000000000 or t2.q_double between -1000000000 and 1000000000']
# tag column where
t_where=['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647',
't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -100000 and t_float <= 100000',
't_double >= -1000000000 and t_double <= 1000000000','t_binary like \'binary%\' or t_binary = \'0\' ','t_nchar like \'nchar%\' or t_nchar = \'0\'',
't_bool = true or t_bool = false','t_bool in (0 , 1)','t_bool in ( true , false)','t_bool = 0 or t_bool = 1',
't_bigint between -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767',
't_tinyint between -127 and 127 ','t_float between -100000 and 100000','t_double between -1000000000 and 1000000000']
#TD-6201,'t_bool between 0 and 1'
# tag column where for test union,join | this is not support
t_u_where=['t1.ts < now +1s','t2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807',
't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647',
't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767',
't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127',
't1.t_float >= -100000 and t1.t_float <= 100000 and t2.t_float >= -100000 and t2.t_float <= 100000',
't1.t_double >= -1000000000 and t1.t_double <= 1000000000 and t2.t_double >= -1000000000 and t2.t_double <= 1000000000',
't1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' ',
't1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' ','t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false',
't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)','t1.t_bool in ( true , false) and t2.t_bool in ( true , false)','t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1',
't1.t_bigint between -9223372036854775807 and 9223372036854775807 and t2.t_bigint between -9223372036854775807 and 9223372036854775807',
't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647',
't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767',
't1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127 ','t1.t_float between -100000 and 100000 and t2.t_float between -100000 and 100000',
't1.t_double between -1000000000 and 1000000000 and t2.t_double between -1000000000 and 1000000000']
#TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1']
t_u_or_where=['t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' ',
't1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' ','t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false',
't1.t_bool in (0 , 1) or t2.t_bool in (0 , 1)','t1.t_bool in ( true , false) or t2.t_bool in ( true , false)','t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1',
't1.t_bigint between -9223372036854775807 and 9223372036854775807 or t2.t_bigint between -9223372036854775807 and 9223372036854775807',
't1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647',
't1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767',
't1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 ','t1.t_float between -100000 and 100000 or t2.t_float between -100000 and 100000',
't1.t_double between -1000000000 and 1000000000 or t2.t_double between -1000000000 and 1000000000']
# regular and tag column where
qt_where=q_where+t_where
qt_u_where=q_u_where+t_u_where
# now,qt_u_or_where is not support
qt_u_or_where=q_u_or_where+t_u_or_where
# tag column where for test super join | this is support , 't1.t_bool = t2.t_bool ' ???
order_u_where=['order by t1.ts','order by t1.ts asc','order by t2.ts','order by t2.ts asc']
order_desc_where=['order by ts','order by ts asc','order by ts desc']
orders_desc_where=['order by ts','order by ts asc','order by ts desc','order by loc','order by loc asc','order by loc desc']
# group by where,not include null-tag
group_where=['group by tbname , loc','group by tbname','group by tbname, t_bigint','group by tbname,t_int','group by tbname, t_smallint','group by tbname,t_tinyint',
'group by tbname,t_float','group by tbname,t_double','group by tbname,t_binary','group by tbname,t_nchar','group by tbname,t_bool','group by tbname ,loc ,t_bigint',
'group by tbname,t_binary ,t_nchar ,t_bool','group by tbname,t_int ,t_smallint ,t_tinyint','group by tbname,t_float ,t_double ']
interp_where=['ts = now','ts = \'2020-09-13 20:26:40.000\'','ts = \'2020-09-13 20:26:40.009\'','tbname in (\'table_1\') and ts = now','tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts = \'2020-09-13 20:26:40.000\'','tbname like \'table%\' and ts = \'2020-09-13 20:26:40.002\'']
't1.tbname in (\'table_1\') and t1.ts = now','t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts = \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\' and t1.ts = \'2020-09-13 20:26:40.002\'',
't2.tbname in (\'table_1\') and t2.ts = now','t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts = \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\' and t2.ts = \'2020-09-13 20:26:40.002\'']
sql="select count(*) from (select count(*) from stable_1 where ts>= 1620000000000 interval(1d) group by tbname) interval(1d);"
tdLog.info(sql)
tdSql.query(sql)
tdSql.checkData(0,0,'2021-08-27 00:00:00.000')
tdSql.checkData(0,1,3)
tdSql.checkData(1,0,'2021-08-28 00:00:00.000')
tdSql.checkData(1,1,3)
tdSql.checkData(2,0,'2021-08-29 00:00:00.000')
tdSql.checkRows(12)
#sql = "select * from ( select * from regular_table_1 where q_tinyint >= -127 and q_tinyint <= 127 order by ts );"
tdSql.query("select 1-2 from table_0;")
sql="select * from ( select * from regular_table_1 where "
sql+="%s );"%random.choice(q_where)
datacheck=self.regular1_checkall_0(sql)
tdSql.checkRows(100)
datacheck=self.regular1_checkall_100(sql)
#sql = "select * from ( select * from regular_table_1 ) where q_binary like 'binary%' or q_binary = '0' order by ts asc ;"
tdSql.query("select 1-3 from table_0;")
sql="select * from ( select * from regular_table_1 ) where "
sql+="%s ;"%random.choice(q_where)
datacheck=self.regular1_checkall_0(sql)
tdSql.checkRows(100)
datacheck=self.regular1_checkall_100(sql)
#sql = select * from ( select * from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and t1.q_double >= -1000000000 and t1.q_double <= 1000000000 and t2.q_double >= -1000000000 and t2.q_double <= 1000000000 order by t2.ts asc );;
tdSql.query("select 1-4 from table_0;")
sql="select * from ( select * from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and "
sql+="%s )"%random.choice(q_u_where)
datacheck=self.regular_join_checkall_0(sql)
tdSql.checkRows(100)
datacheck=self.regular_join_checkall_100(sql)
#sql = "select * from ( select * from stable_1 where q_tinyint >= -127 and q_tinyint <= 127 order by ts );"
tdSql.query("select 2-1 from stable_1;")
sql="select * from ( select * from stable_1 where "
sql+="%s );"%random.choice(qt_where)
datacheck=self.stable1_checkall_0(sql)
tdSql.checkRows(300)
datacheck=self.stable1_checkall_300(sql)
#sql = "select * from ( select * from stable_1 ) order by ts asc ;"
tdSql.query("select 2-2 from stable_1;")
sql="select * from ( select * from stable_1 ) where "
sql+="%s ;"%random.choice(qt_where)
datacheck=self.stable1_checkall_0(sql)
tdSql.checkRows(300)
datacheck=self.stable1_checkall_300(sql)
#sql = "select * from ( select * from table_0 ) where q_binary like 'binary%' or q_binary = '0' order by ts asc ;"
tdSql.query("select 2-3 from stable_1;")
sql="select * from ( select * from table_0 ) where "
sql+="%s ;"%random.choice(q_where)
datacheck=self.regular1_checkall_0(sql)
tdSql.checkRows(100)
datacheck=self.regular1_checkall_100(sql)
#sql = "select * from ( select * from table_0 where q_binary like 'binary%' or q_binary = '0' order by ts asc );"
tdSql.query("select 2-4 from stable_1;")
sql="select * from ( select * from table_0 where "
sql+="%s );"%random.choice(q_where)
datacheck=self.regular1_checkall_0(sql)
tdSql.checkRows(100)
datacheck=self.regular1_checkall_100(sql)
#sql = select * from ( select * from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and t1.t_int = t2.t_int ) ;;
tdSql.query("select 2-5 from stable_1;")
sql="select * from ( select * from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb1.ts>=100000 interval(1s) fill(linear);
sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb1.ts>=100000 interval(1s);