tdSql.query(f'select {table_name_sub1},{table_name_sub2},{table_name_sub3},{table_name_sub4},{table_name_sub5},{table_name_sub6},{table_name_sub7},{table_name_sub8},{table_name_sub9} from {table_name} where tbname in ("{table_name_sub1}","{table_name_sub2}","{table_name_sub3}","{table_name_sub4}","{table_name_sub5}","{table_name_sub6}","{table_name_sub7}","{table_name_sub8}","{table_name_sub9}") and ts >= "1980-01-01 00:00:00.000"')
this test case is an test case for unexpectd error for taosd work error ,it maybe caused by ;
'''
return
defrun(self):
tdSql.prepare()
tdSql.execute("create database if not exists testdb keep 36500;")
tdSql.execute("use testdb;")
tdSql.execute("create stable st (ts timestamp , id int , value double) tags(hostname binary(10) ,ind int);")
foriinrange(self.num):
tdSql.execute("insert into sub_%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+100*i,i*2,i+10.00))
tdSql.execute("insert into sub_%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+200*i,i*2,i+10.00))
tdSql.execute("insert into sub_%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+300*i,i*2,i+10.00))
tdSql.execute("insert into sub_%s using st tags('host_%s' , %d) values (%d , %d , %f );"%(str(i),str(i),i*10,self.ts+10000*i,i*2,i+10.00))
cfg_path=self.getcfgPath()
print(cfg_path)
tdSql.execute('select elapsed(ts,10s) from testdb.st where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" session(ts,1d) group by tbname;')
datas=tdSql.getResult('select elapsed(ts,10s) from testdb.st where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" session(ts,1d) group by tbname;')
table_names=["sub_%s"%str(i)foriinrange(10)]
# print(table_names)
# prepare data for generate draft
forindex,table_nameinenumerate(table_names):
tdSql.query("select elapsed(ts,10s) from testdb.%s where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" session(ts,1d) ;"%table_name)
taos_cmd1="taos -c %s -s 'select elapsed(ts,10s) from testdb.st where ts>=\"2015-01-01 00:00:00.000\" and ts < \"2015-01-01 00:10:00.000\" session(ts,1d) group by tbname;' "%(cfg_path)
tdSql.execute("create table db.`%s` as select avg(`%s`) from db.`%s` where ts > now interval(1m) sliding(30s);"%(self.cr_tb1,self.col_bigint,self.stb1))
tdSql.query("show db.tables like 'create_table_%' ")
tdSql.checkRows(1)
print("==============drop\ add\ change\ modify column or tag")
print("==============drop==============")
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_ts))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(21)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_double))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(20)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_float))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(19)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_nchar))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(18)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_binary))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(17)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_bool))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(16)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_tinyint))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(15)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_smallint))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(14)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_bigint))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(13)
tdSql.execute("ALTER TABLE db.`%s` DROP TAG `%s`; "%(self.stb1,self.tag_int))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(12)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_ts))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_9(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(11)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_double))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_8(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(10)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_float))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_7(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(9)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_nchar))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_6(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(8)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_binary))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_5(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(7)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_bool))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_4(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(6)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_tinyint))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_3(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(5)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_smallint))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_2(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(4)
tdSql.execute("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_bigint))
sql=" select * from db.`%s`; "%self.stb1
datacheck=self.table1_checkall_1(sql)
tdSql.query("describe db.`%s` ; "%self.tb1)
tdSql.checkRows(3)
tdSql.error("ALTER TABLE db.`%s` DROP COLUMN `%s`; "%(self.stb1,self.col_int))
sql=" select * from db2.`%s`; "%self.regular_table
datacheck=self.table1_checkall(sql)
tdSql.checkRows(2)
sql=" select * from db2.`%s` where `%s`=1 and `%s`=2 and `%s`=3 and `%s`=4 and `%s`='True' and `%s`=6 and `%s`=7 and `%s`=8 and `%s`=9 and `%s`=10; " \