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; " \
case1:<wenzhouwww>: [TD-11945] this test case is an issue about taoshell and taosd crash , it now has been repaired on branch https://github.com/taosdata/TDengine/tree/feature%2FTD-6140
the root source maybe :
The four arithmetic operations do not perform the verification of the numeric type,so that the numeric type and string type will coredump about Four arithmetic operations
'''
return
definit(self,conn,logSql):
tdLog.debug("start test case for TD-11945 execute %s"%__file__)
tdSql.init(conn.cursor(),logSql)
self.ts=1420041600000# 2015-01-01 00:00:00 this is begin time for first record
self.num=10
defrun(self):
tdSql.prepare()
tdSql.execute('create database if not exists testdb')
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+10000*i,i*2,i+10.00))
tdSql.query('select elapsed(ts,10s) from sub_1 where ts>="2015-01-01 00:00:00.000" and ts < "2015-01-01 00:10:00.000" session(ts,1d) ;')
cfg_path=self.getcfgPath()
print(cfg_path)
# tdSql.execute('select elapsed(ts,10s) from 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;') # session not support super table
os.system("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))
f"restful timestamp column err, url:{url}, sql: {data},result is: {res_data[col_index]}"
)
return
except:
traceback.print_exc()
raise
pass
defsql_case_current(self):
case_list=[
"show databases",
f"show {self.dbname}.stables",
f"show {self.dbname}.tables",
"select server_status()",
"select client_version()",
"select server_version()",
"select database()",
f"show create database {self.dbname}",
f"show create stable {self.dbname}.stb1",
f"select * from {self.dbname}.stb1",
f"select ts from {self.dbname}.stb1",
f"select _c0 from {self.dbname}.stb1",
f"select c1 from {self.dbname}.stb1",
f"select c2 from {self.dbname}.stb1",
f"select c3 from {self.dbname}.stb1",
f"select c4 from {self.dbname}.stb1",
f"select c5 from {self.dbname}.stb1",
f"select c6 from {self.dbname}.stb1",
f"select c7 from {self.dbname}.stb1",
f"select c8 from {self.dbname}.stb1",
f"select c9 from {self.dbname}.stb1",
f"select c10 from {self.dbname}.stb1",
f"select tbname from {self.dbname}.stb1",
f"select tag1 from {self.dbname}.stb1",
f"select tag2 from {self.dbname}.stb1",
f"select tag3 from {self.dbname}.stb1",
f"select tag4 from {self.dbname}.stb1",
f"select tag5 from {self.dbname}.stb1",
f"select tag6 from {self.dbname}.stb1",
f"select tag7 from {self.dbname}.stb1",
f"select tag8 from {self.dbname}.stb1",
f"select tag9 from {self.dbname}.stb1",
f"select tag10 from {self.dbname}.stb1",
f"select count(*) from {self.dbname}.stb1",
f"select count(c1) from {self.dbname}.stb1",
f"select avg(c1) from {self.dbname}.stb1",
f"select twa(c1) from {self.dbname}.stb1 group by tbname",
f"select sum(c1) from {self.dbname}.stb1",
f"select stddev(c1) from {self.dbname}.stb1",
f"select min(c1) from {self.dbname}.stb1",
f"select max(c1) from {self.dbname}.stb1",
f"select first(c1) from {self.dbname}.stb1",
f"select first(*) from {self.dbname}.stb1",
f"select last(c1) from {self.dbname}.stb1",
f"select last(*) from {self.dbname}.stb1",
f"select top(c1, 3) from {self.dbname}.stb1",
f"select bottom(c1, 3) from {self.dbname}.stb1",
f"select apercentile(c1, 50, 't-digest') from {self.dbname}.stb1",
f"select last_row(c1) from {self.dbname}.stb1",
f"select last_row(*) from {self.dbname}.stb1",
f"select interp(c1) from {self.dbname}.stb1 where ts=0 group by tbname",
f"select interp(c1) from {self.dbname}.stb1 where ts=0 fill(next) group by tbname",
f"select interp(c1) from {self.dbname}.stb1 where ts>0 and ts <100000000 every(5s) group by tbname",
f"select diff(c1) from {self.dbname}.stb1 group by tbname",
f"select derivative(c1, 10m, 0) from {self.dbname}.stb1 group by tbname",
f"select derivative(c1, 10m, 1) from {self.dbname}.stb1 group by tbname",
f"select spread(c1) from {self.dbname}.stb1",
f"select ceil(c1) from {self.dbname}.stb1",
f"select floor(c1) from {self.dbname}.stb1",
f"select round(c1) from {self.dbname}.stb1",
f"select c1*2+2%c2-c2/2 from {self.dbname}.stb1",
f"select max(c1) from {self.dbname}.stb1 where ts>'2021-12-05 18:25:41.136' and ts<'2021-12-05 18:25:44.13' interval(1s) sliding(500a) fill(NULL) group by tbname",
f"select max(c1) from {self.dbname}.stb1 where (c1 >=0 and c1 <> 0 and c2 is not null or c1 < -1 or (c2 between 1 and 10) ) and tbname like 't_' ",
f"select max(c1) from {self.dbname}.stb1 group by tbname order by ts desc slimit 2 soffset 2 limit 1 offset 0",
f"select max(c1) from {self.dbname}.stb1 group by c6 order by ts desc slimit 1 soffset 1 limit 1 offset 0 ",
f"select * from {self.dbname}.t1",
f"select ts from {self.dbname}.t1",
f"select _c0 from {self.dbname}.t1",
f"select c1 from {self.dbname}.t1",
f"select c2 from {self.dbname}.t1",
f"select c3 from {self.dbname}.t1",
f"select c4 from {self.dbname}.t1",
f"select c5 from {self.dbname}.t1",
f"select c6 from {self.dbname}.t1",
f"select c7 from {self.dbname}.t1",
f"select c8 from {self.dbname}.t1",
f"select c9 from {self.dbname}.t1",
f"select c10 from {self.dbname}.t1",
f"select tbname from {self.dbname}.t1",
f"select tag1 from {self.dbname}.t1",
f"select tag2 from {self.dbname}.t1",
f"select tag3 from {self.dbname}.t1",
f"select tag4 from {self.dbname}.t1",
f"select tag5 from {self.dbname}.t1",
f"select tag6 from {self.dbname}.t1",
f"select tag7 from {self.dbname}.t1",
f"select tag8 from {self.dbname}.t1",
f"select tag9 from {self.dbname}.t1",
f"select tag10 from {self.dbname}.t1",
f"select count(*) from {self.dbname}.t1",
f"select count(c1) from {self.dbname}.t1",
f"select avg(c1) from {self.dbname}.t1",
f"select twa(c1) from {self.dbname}.t1",
f"select sum(c1) from {self.dbname}.t1",
f"select stddev(c1) from {self.dbname}.t1",
f"select leastsquares(c1, 1, 1) from {self.dbname}.t1",
f"select min(c1) from {self.dbname}.t1",
f"select max(c1) from {self.dbname}.t1",
f"select first(c1) from {self.dbname}.t1",
f"select first(*) from {self.dbname}.t1",
f"select last(c1) from {self.dbname}.t1",
f"select last(*) from {self.dbname}.t1",
f"select top(c1, 3) from {self.dbname}.t1",
f"select bottom(c1, 3) from {self.dbname}.t1",
f"select percentile(c1, 50) from {self.dbname}.t1",
f"select apercentile(c1, 50, 't-digest') from {self.dbname}.t1",
f"select last_row(c1) from {self.dbname}.t1",
f"select last_row(*) from {self.dbname}.t1",
f"select interp(c1) from {self.dbname}.t1 where ts=0 ",
f"select interp(c1) from {self.dbname}.t1 where ts=0 fill(next)",
f"select interp(c1) from {self.dbname}.t1 where ts>0 and ts <100000000 every(5s)",
f"select diff(c1) from {self.dbname}.t1",
f"select derivative(c1, 10m, 0) from {self.dbname}.t1",
f"select derivative(c1, 10m, 1) from {self.dbname}.t1",
f"select spread(c1) from {self.dbname}.t1",
f"select ceil(c1) from {self.dbname}.t1",
f"select floor(c1) from {self.dbname}.t1",
f"select round(c1) from {self.dbname}.t1",
f"select c1*2+2%c2-c2/2 from {self.dbname}.t1",
f"select max(c1) from {self.dbname}.t1 where ts>'2021-12-05 18:25:41.136' and ts<'2021-12-05 18:25:44.13' interval(1s) sliding(500a) fill(NULL)",
f"select max(c1) from {self.dbname}.t1 where (c1 >=0 and c1 <> 0 and c2 is not null or c1 < -1 or (c2 between 1 and 10) ) and c10 like 'nchar___1' ",
f"select max(c1) from {self.dbname}.t1 group by c6 order by ts desc ",
f"select stb1.c1, stb2.c1 from {self.dbname}.stb1 stb1, {self.dbname}.stb2 stb2 where stb1.ts=stb2.ts and stb1.tag1=stb2.ttag1",
f"select t1.c1, t2.c1 from {self.dbname}.t1 t1, {self.dbname}.t2 t2 where t1.ts=t2.ts",
f"select c1 from (select c2 c1 from {self.dbname}.stb1) ",
f"select c1 from {self.dbname}.t1 union all select c1 from {self.dbname}.t2"
]
returncase_list
defsql_case_err(self):
case_list=[
"show database",
f"select percentile(c1, 50) from {self.dbname}.stb1 group by tbname",
f"select leastsquares(c1, 1, 1) from {self.dbname}.stb1",