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 >= -1.7E308 and q_float <= 1.7E308',
'q_double >= -1.7E308 and q_double <= 1.7E308','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 >= -3.4E38 ','q_float <= 3.4E38 ','q_double >= -1.7E308 ',
'q_double <= 1.7E308 ','q_float between -3.4E38 and 3.4E38 ','q_double between -1.7E308 and 1.7E308 ',
'q_float is not null ','q_double is not null ',]
#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 >= - 1.7E308 and t1.q_float <= 1.7E308 and t2.q_float >= - 1.7E308 and t2.q_float <= 1.7E308',
't1.q_double >= - 1.7E308 and t1.q_double <= 1.7E308 and t2.q_double >= - 1.7E308 and t2.q_double <= 1.7E308',
'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 -1.7E308 and 1.7E308 and t2.q_float between -1.7E308 and 1.7E308',
't1.q_double between -1.7E308 and 1.7E308 and t2.q_double between -1.7E308 and 1.7E308']
#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 -1.7E308 and 1.7E308 or t2.q_float between -1.7E308 and 1.7E308)',
'(t1.q_double between -1.7E308 and 1.7E308 or t2.q_double between -1.7E308 and 1.7E308)']
# 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 >= -1.7E308 and t_float <= 1.7E308',
't_double >= -1.7E308 and t_double <= 1.7E308','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 -1.7E308 and 1.7E308','t_double between -1.7E308 and 1.7E308']
#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 >= -1.7E308 and t1.t_float <= 1.7E308 and t2.t_float >= -1.7E308 and t2.t_float <= 1.7E308',
't1.t_double >= -1.7E308 and t1.t_double <= 1.7E308 and t2.t_double >= -1.7E308 and t2.t_double <= 1.7E308',
'(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 -1.7E308 and 1.7E308 and t2.t_float between -1.7E308 and 1.7E308',
'(t1.t_double between -1.7E308 and 1.7E308 and t2.t_double between -1.7E308 and 1.7E308)']
#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 -1.7E308 and 1.7E308 or t2.t_float between -1.7E308 and 1.7E308)',
'(t1.t_double between -1.7E308 and 1.7E308 or t2.t_double between -1.7E308 and 1.7E308)']
# 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_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\'']
#16 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by limit offset )
#self.dropandcreateDB_random("%s" %db, 1)
tdSql.query("select 16-1 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_0 , "%random.choice(calc_calculate_all)
sql+="%s as calc16_1 , "%random.choice(calc_aggregate_all)
sql+="%s as calc16_2 "%random.choice(calc_select_in)
sql+=" from stable_1 where "
sql+="%s "%random.choice(q_where)
sql+="%s "%random.choice(group_where)
sql+="%s "%random.choice(having_support)
sql+=") "
sql+="order by calc16_0 "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# TD-15497 tdSql.query(sql)
# tdSql.checkRows(1)
tdSql.query("select 16-2 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_0 "%random.choice(calc_calculate_all_j)
sql+=", %s as calc16_1 "%random.choice(calc_aggregate_all_j)
#sql += ", %s as calc16_2 " % random.choice(calc_select_in_j)
sql+=" from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
sql+="%s "%random.choice(t_join_where)
sql+=") "
sql+="order by calc16_0 "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
#TD-15493 tdSql.query(sql)
tdSql.query("select 16-2.2 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_0 "%random.choice(calc_calculate_all_j)
sql+=", %s as calc16_1 "%random.choice(calc_aggregate_all_j)
sql+=" from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
sql+="%s "%random.choice(qt_u_or_where)
sql+=") "
sql+="order by calc16_0 "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.error(sql)
tdSql.query("select 16-3 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 "%random.choice(calc_calculate_regular)
sql+=" from regular_table_1 where "
sql+="%s "%random.choice(q_where)
sql+="limit 2 ) "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.query(sql)
# tdSql.checkRows(1)
tdSql.query("select 16-4 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 "%random.choice(calc_calculate_regular_j)
sql+=" from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and "
sql+="%s "%random.choice(q_u_where)
sql+="limit 2 ) "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.query(sql)
# tdSql.checkRows(1)
tdSql.query("select 16-4.2 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 "%random.choice(calc_calculate_regular_j)
sql+=" from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and "
sql+="%s "%random.choice(q_u_or_where)
sql+="limit 2 ) "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.error(sql)
tdSql.query("select 16-5 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 , "%random.choice(calc_calculate_all)
sql+="%s as calc16_1 , "%random.choice(calc_calculate_regular)
sql+="%s as calc16_2 "%random.choice(calc_select_all)
sql+=" from stable_1 where "
sql+="%s "%random.choice(q_where)
sql+="%s "%random.choice(group_where)
sql+="%s "%random.choice(having_support)
sql+=") "
sql+="order by calc16_1 "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.error(sql)
tdSql.query("select 16-6 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 "%random.choice(calc_calculate_groupbytbname)
sql+=" from stable_1 where "
sql+="%s "%random.choice(q_where)
sql+="%s "%random.choice(group_where)
sql+="limit 2 ) "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.query(sql)
# tdSql.checkRows(1)
tdSql.query("select 16-7 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 "%random.choice(calc_calculate_groupbytbname_j)
sql+=" from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
sql+="%s "%random.choice(t_join_where)
sql+="limit 2 ) "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.error(sql)
tdSql.query("select 16-8 from stable_1;")
foriinrange(self.fornum):
sql="select * from ( select "
sql+="%s as calc16_1 "%random.choice(calc_calculate_groupbytbname_j)
sql+=" from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
sql+="%s "%random.choice(qt_u_or_where)
sql+="limit 2 ) "
sql+="%s "%random.choice(limit1_where)
tdLog.info(sql)
tdLog.info(len(sql))
# tdSql.error(sql)
#17 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or interval_sliding group by having order by limit offset )interval_sliding
#self.dropandcreateDB_random("%s" %db, 1)
tdSql.query("select 17-1 from stable_1;")
foriinrange(self.fornum):
#this is having_support , but tag-select cannot mix with last_row,other select can
tdLog.printNoPrefix("======== test case 3 end ...... ")
tdLog.printNoPrefix("======== test case 4 end ...... ")
deftmqCase5(self,cfgPath,buildPath):
tdLog.printNoPrefix("======== test case 5: Produce while two consumers to subscribe one db, firstly create one stb, after start consume create other stb")
tdLog.info("step 1: create database, stb, ctb and insert data")
# create and start thread
parameterDict={'cfg':'', \
'dbName':'db5', \
'vgroups':4, \
'stbName':'stb', \
'ctbNum':10, \
'rowsPerTbl':10000, \
'batchNum':100, \
'startTs':1640966400000}# 2022-01-01 00:00:00.000
parameterDict['cfg']=cfgPath
self.initConsumerTable()
tdSql.execute("create database if not exists %s vgroups %d"%(parameterDict['dbName'],parameterDict['vgroups']))