tdLog.info("floor value check pass , it work as expected ,sql is \"%s\" "%floor_query)
tdLog.info("floor value check pass , it work as expected ,sql is \"%s\" "%floor_query)
deftest_errors(self):
deftest_errors(self,dbname=DBNAME):
error_sql_lists=[
error_sql_lists=[
"select floor from t1",
f"select floor from {dbname}.t1",
# "select floor(-+--+c1) from t1",
# f"select floor(-+--+c1) from {dbname}.t1",
# "select +-floor(c1) from t1",
# f"select +-floor(c1) from {dbname}.t1",
# "select ++-floor(c1) from t1",
# f"select ++-floor(c1) from {dbname}.t1",
# "select ++--floor(c1) from t1",
# f"select ++--floor(c1) from {dbname}.t1",
# "select - -floor(c1)*0 from t1",
# f"select - -floor(c1)*0 from {dbname}.t1",
# "select floor(tbname+1) from t1 ",
# f"select floor(tbname+1) from {dbname}.t1 ",
"select floor(123--123)==1 from t1",
f"select floor(123--123)==1 from {dbname}.t1",
"select floor(c1) as 'd1' from t1",
f"select floor(c1) as 'd1' from {dbname}.t1",
"select floor(c1 ,c2 ) from t1",
f"select floor(c1 ,c2 ) from {dbname}.t1",
"select floor(c1 ,NULL) from t1",
f"select floor(c1 ,NULL) from {dbname}.t1",
"select floor(,) from t1;",
f"select floor(,) from {dbname}.t1;",
"select floor(floor(c1) ab from t1)",
f"select floor(floor(c1) ab from {dbname}.t1)",
"select floor(c1) as int from t1",
f"select floor(c1) as int from {dbname}.t1",
"select floor from stb1",
f"select floor from {dbname}.stb1",
# "select floor(-+--+c1) from stb1",
# f"select floor(-+--+c1) from {dbname}.stb1",
# "select +-floor(c1) from stb1",
# f"select +-floor(c1) from {dbname}.stb1",
# "select ++-floor(c1) from stb1",
# f"select ++-floor(c1) from {dbname}.stb1",
# "select ++--floor(c1) from stb1",
# f"select ++--floor(c1) from {dbname}.stb1",
# "select - -floor(c1)*0 from stb1",
# f"select - -floor(c1)*0 from {dbname}.stb1",
# "select floor(tbname+1) from stb1 ",
# f"select floor(tbname+1) from {dbname}.stb1 ",
"select floor(123--123)==1 from stb1",
f"select floor(123--123)==1 from {dbname}.stb1",
"select floor(c1) as 'd1' from stb1",
f"select floor(c1) as 'd1' from {dbname}.stb1",
"select floor(c1 ,c2 ) from stb1",
f"select floor(c1 ,c2 ) from {dbname}.stb1",
"select floor(c1 ,NULL) from stb1",
f"select floor(c1 ,NULL) from {dbname}.stb1",
"select floor(,) from stb1;",
f"select floor(,) from {dbname}.stb1;",
"select floor(floor(c1) ab from stb1)",
f"select floor(floor(c1) ab from {dbname}.stb1)",
"select floor(c1) as int from stb1"
f"select floor(c1) as int from {dbname}.stb1"
]
]
forerror_sqlinerror_sql_lists:
forerror_sqlinerror_sql_lists:
tdSql.error(error_sql)
tdSql.error(error_sql)
defsupport_types(self):
defsupport_types(self,dbname=DBNAME):
type_error_sql_lists=[
type_error_sql_lists=[
"select floor(ts) from t1",
f"select floor(ts) from {dbname}.t1",
"select floor(c7) from t1",
f"select floor(c7) from {dbname}.t1",
"select floor(c8) from t1",
f"select floor(c8) from {dbname}.t1",
"select floor(c9) from t1",
f"select floor(c9) from {dbname}.t1",
"select floor(ts) from ct1",
f"select floor(ts) from {dbname}.ct1",
"select floor(c7) from ct1",
f"select floor(c7) from {dbname}.ct1",
"select floor(c8) from ct1",
f"select floor(c8) from {dbname}.ct1",
"select floor(c9) from ct1",
f"select floor(c9) from {dbname}.ct1",
"select floor(ts) from ct3",
f"select floor(ts) from {dbname}.ct3",
"select floor(c7) from ct3",
f"select floor(c7) from {dbname}.ct3",
"select floor(c8) from ct3",
f"select floor(c8) from {dbname}.ct3",
"select floor(c9) from ct3",
f"select floor(c9) from {dbname}.ct3",
"select floor(ts) from ct4",
f"select floor(ts) from {dbname}.ct4",
"select floor(c7) from ct4",
f"select floor(c7) from {dbname}.ct4",
"select floor(c8) from ct4",
f"select floor(c8) from {dbname}.ct4",
"select floor(c9) from ct4",
f"select floor(c9) from {dbname}.ct4",
"select floor(ts) from stb1",
f"select floor(ts) from {dbname}.stb1",
"select floor(c7) from stb1",
f"select floor(c7) from {dbname}.stb1",
"select floor(c8) from stb1",
f"select floor(c8) from {dbname}.stb1",
"select floor(c9) from stb1",
f"select floor(c9) from {dbname}.stb1",
"select floor(ts) from stbbb1",
f"select floor(ts) from {dbname}.stbbb1",
"select floor(c7) from stbbb1",
f"select floor(c7) from {dbname}.stbbb1",
"select floor(ts) from tbname",
f"select floor(ts) from {dbname}.tbname",
"select floor(c9) from tbname"
f"select floor(c9) from {dbname}.tbname"
]
]
...
@@ -165,127 +165,127 @@ class TDTestCase:
...
@@ -165,127 +165,127 @@ class TDTestCase:
type_sql_lists=[
type_sql_lists=[
"select floor(c1) from t1",
f"select floor(c1) from {dbname}.t1",
"select floor(c2) from t1",
f"select floor(c2) from {dbname}.t1",
"select floor(c3) from t1",
f"select floor(c3) from {dbname}.t1",
"select floor(c4) from t1",
f"select floor(c4) from {dbname}.t1",
"select floor(c5) from t1",
f"select floor(c5) from {dbname}.t1",
"select floor(c6) from t1",
f"select floor(c6) from {dbname}.t1",
"select floor(c1) from ct1",
f"select floor(c1) from {dbname}.ct1",
"select floor(c2) from ct1",
f"select floor(c2) from {dbname}.ct1",
"select floor(c3) from ct1",
f"select floor(c3) from {dbname}.ct1",
"select floor(c4) from ct1",
f"select floor(c4) from {dbname}.ct1",
"select floor(c5) from ct1",
f"select floor(c5) from {dbname}.ct1",
"select floor(c6) from ct1",
f"select floor(c6) from {dbname}.ct1",
"select floor(c1) from ct3",
f"select floor(c1) from {dbname}.ct3",
"select floor(c2) from ct3",
f"select floor(c2) from {dbname}.ct3",
"select floor(c3) from ct3",
f"select floor(c3) from {dbname}.ct3",
"select floor(c4) from ct3",
f"select floor(c4) from {dbname}.ct3",
"select floor(c5) from ct3",
f"select floor(c5) from {dbname}.ct3",
"select floor(c6) from ct3",
f"select floor(c6) from {dbname}.ct3",
"select floor(c1) from stb1",
f"select floor(c1) from {dbname}.stb1",
"select floor(c2) from stb1",
f"select floor(c2) from {dbname}.stb1",
"select floor(c3) from stb1",
f"select floor(c3) from {dbname}.stb1",
"select floor(c4) from stb1",
f"select floor(c4) from {dbname}.stb1",
"select floor(c5) from stb1",
f"select floor(c5) from {dbname}.stb1",
"select floor(c6) from stb1",
f"select floor(c6) from {dbname}.stb1",
"select floor(c6) as alisb from stb1",
f"select floor(c6) as alisb from {dbname}.stb1",
"select floor(c6) alisb from stb1",
f"select floor(c6) alisb from {dbname}.stb1",
]
]
fortype_sqlintype_sql_lists:
fortype_sqlintype_sql_lists:
tdSql.query(type_sql)
tdSql.query(type_sql)
defbasic_floor_function(self):
defbasic_floor_function(self,dbname=DBNAME):
# basic query
# basic query
tdSql.query("select c1 from ct3")
tdSql.query(f"select c1 from {dbname}.ct3")
tdSql.checkRows(0)
tdSql.checkRows(0)
tdSql.query("select c1 from t1")
tdSql.query(f"select c1 from {dbname}.t1")
tdSql.checkRows(12)
tdSql.checkRows(12)
tdSql.query("select c1 from stb1")
tdSql.query(f"select c1 from {dbname}.stb1")
tdSql.checkRows(25)
tdSql.checkRows(25)
# used for empty table , ct3 is empty
# used for empty table , ct3 is empty
tdSql.query("select floor(c1) from ct3")
tdSql.query(f"select floor(c1) from {dbname}.ct3")
tdSql.checkRows(0)
tdSql.checkRows(0)
tdSql.query("select floor(c2) from ct3")
tdSql.query(f"select floor(c2) from {dbname}.ct3")
tdSql.checkRows(0)
tdSql.checkRows(0)
tdSql.query("select floor(c3) from ct3")
tdSql.query(f"select floor(c3) from {dbname}.ct3")
tdSql.checkRows(0)
tdSql.checkRows(0)
tdSql.query("select floor(c4) from ct3")
tdSql.query(f"select floor(c4) from {dbname}.ct3")
tdSql.checkRows(0)
tdSql.checkRows(0)
tdSql.query("select floor(c5) from ct3")
tdSql.query(f"select floor(c5) from {dbname}.ct3")
tdSql.checkRows(0)
tdSql.checkRows(0)
tdSql.query("select floor(c6) from ct3")
tdSql.query(f"select floor(c6) from {dbname}.ct3")
# used for regular table
# used for regular table
tdSql.query("select floor(c1) from t1")
tdSql.query(f"select floor(c1) from {dbname}.t1")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,1)
tdSql.checkData(1,0,1)
tdSql.checkData(3,0,3)
tdSql.checkData(3,0,3)
tdSql.checkData(5,0,None)
tdSql.checkData(5,0,None)
tdSql.query("select c1, c2, c3 , c4, c5 from t1")
tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1")
tdSql.checkData(1,4,1.11000)
tdSql.checkData(1,4,1.11000)
tdSql.checkData(3,3,33)
tdSql.checkData(3,3,33)
tdSql.checkData(5,4,None)
tdSql.checkData(5,4,None)
tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1")
tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1")
tdSql.checkData(1,5,1.11000)
tdSql.checkData(1,5,1.11000)
tdSql.checkData(3,4,33)
tdSql.checkData(3,4,33)
tdSql.checkData(5,5,None)
tdSql.checkData(5,5,None)
self.check_result_auto("select c1, c2, c3 , c4, c5 from t1","select (c1), floor(c2) ,floor(c3), floor(c4), floor(c5) from t1")
self.check_result_auto(f"select c1, c2, c3 , c4, c5 from {dbname}.t1",f"select (c1), floor(c2) ,floor(c3), floor(c4), floor(c5) from {dbname}.t1")
# used for sub table
# used for sub table
tdSql.query("select floor(c1) from ct1")
tdSql.query(f"select floor(c1) from {dbname}.ct1")
tdSql.checkData(0,0,8)
tdSql.checkData(0,0,8)
tdSql.checkData(1,0,7)
tdSql.checkData(1,0,7)
tdSql.checkData(3,0,5)
tdSql.checkData(3,0,5)
tdSql.checkData(5,0,4)
tdSql.checkData(5,0,4)
tdSql.query("select floor(c1) from ct1")
tdSql.query(f"select floor(c1) from {dbname}.ct1")
self.check_result_auto("select c1, c2, c3 , c4, c5 from ct1","select (c1), floor(c2) ,floor(c3), floor(c4), floor(c5) from ct1")
self.check_result_auto(f"select c1, c2, c3 , c4, c5 from {dbname}.ct1",f"select (c1), floor(c2) ,floor(c3), floor(c4), floor(c5) from {dbname}.ct1")
self.check_result_auto("select floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(c1)))))))))) nest_col_func from ct1;","select c1 from ct1")
self.check_result_auto(f"select floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(c1)))))))))) nest_col_func from {dbname}.ct1;",f"select c1 from {dbname}.ct1")
# used for stable table
# used for stable table
tdSql.query("select floor(c1) from stb1")
tdSql.query(f"select floor(c1) from {dbname}.stb1")
tdSql.checkRows(25)
tdSql.checkRows(25)
self.check_result_auto("select c1, c2, c3 , c4, c5 from ct4 ","select (c1), floor(c2) ,floor(c3), floor(c4), floor(c5) from ct4")
self.check_result_auto(f"select c1, c2, c3 , c4, c5 from {dbname}.ct4 ",f"select (c1), floor(c2) ,floor(c3), floor(c4), floor(c5) from {dbname}.ct4")
self.check_result_auto("select floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(c1)))))))))) nest_col_func from ct4;","select c1 from ct4")
self.check_result_auto(f"select floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(c1)))))))))) nest_col_func from {dbname}.ct4;",f"select c1 from {dbname}.ct4")
# used for not exists table
# used for not exists table
tdSql.error("select floor(c1) from stbbb1")
tdSql.error(f"select floor(c1) from {dbname}.stbbb1")
tdSql.error("select floor(c1) from tbname")
tdSql.error(f"select floor(c1) from {dbname}.tbname")
tdSql.error("select floor(c1) from ct5")
tdSql.error(f"select floor(c1) from {dbname}.ct5")
# mix with common col
# mix with common col
tdSql.query("select c1, floor(c1) from ct1")
tdSql.query(f"select c1, floor(c1) from {dbname}.ct1")
tdSql.checkData(0,0,8)
tdSql.checkData(0,0,8)
tdSql.checkData(0,1,8)
tdSql.checkData(0,1,8)
tdSql.checkData(4,0,0)
tdSql.checkData(4,0,0)
tdSql.checkData(4,1,0)
tdSql.checkData(4,1,0)
tdSql.query("select c1, floor(c1) from ct4")
tdSql.query(f"select c1, floor(c1) from {dbname}.ct4")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(4,0,5)
tdSql.checkData(4,0,5)
tdSql.checkData(4,1,5)
tdSql.checkData(4,1,5)
tdSql.checkData(5,0,None)
tdSql.checkData(5,0,None)
tdSql.checkData(5,1,None)
tdSql.checkData(5,1,None)
tdSql.query("select c1, floor(c1) from ct4 ")
tdSql.query(f"select c1, floor(c1) from {dbname}.ct4 ")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(4,0,5)
tdSql.checkData(4,0,5)
tdSql.checkData(4,1,5)
tdSql.checkData(4,1,5)
# mix with common functions
# mix with common functions
tdSql.query("select c1, floor(c1),c5, floor(c5) from ct4 ")
tdSql.query(f"select c1, floor(c1),c5, floor(c5) from {dbname}.ct4 ")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,2,None)
tdSql.checkData(0,2,None)
...
@@ -296,34 +296,34 @@ class TDTestCase:
...
@@ -296,34 +296,34 @@ class TDTestCase:
tdSql.checkData(3,2,6.66000)
tdSql.checkData(3,2,6.66000)
tdSql.checkData(3,3,6.00000)
tdSql.checkData(3,3,6.00000)
tdSql.query("select c1, floor(c1),c5, floor(c5) from stb1 ")
tdSql.query(f"select c1, floor(c1),c5, floor(c5) from {dbname}.stb1 ")
# mix with agg functions , not support
# mix with agg functions , not support
tdSql.error("select c1, floor(c1),c5, count(c5) from stb1 ")
tdSql.error(f"select c1, floor(c1),c5, count(c5) from {dbname}.stb1 ")
tdSql.error("select c1, floor(c1),c5, count(c5) from ct1 ")
tdSql.error(f"select c1, floor(c1),c5, count(c5) from {dbname}.ct1 ")
tdSql.error("select floor(c1), count(c5) from stb1 ")
tdSql.error(f"select floor(c1), count(c5) from {dbname}.stb1 ")
tdSql.error("select floor(c1), count(c5) from ct1 ")
tdSql.error(f"select floor(c1), count(c5) from {dbname}.ct1 ")
tdSql.error("select c1, count(c5) from ct1 ")
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
tdSql.error("select c1, count(c5) from stb1 ")
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
# agg functions mix with agg functions
# agg functions mix with agg functions
tdSql.query("select max(c5), count(c5) from stb1")
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
tdSql.query("select max(c5), count(c5) from ct1")
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
# bug fix for count
# bug fix for count
tdSql.query("select count(c1) from ct4 ")
tdSql.query(f"select count(c1) from {dbname}.ct4 ")
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,9)
tdSql.query("select count(*) from ct4 ")
tdSql.query(f"select count(*) from {dbname}.ct4 ")
tdSql.checkData(0,0,12)
tdSql.checkData(0,0,12)
tdSql.query("select count(c1) from stb1 ")
tdSql.query(f"select count(c1) from {dbname}.stb1 ")
tdSql.checkData(0,0,22)
tdSql.checkData(0,0,22)
tdSql.query("select count(*) from stb1 ")
tdSql.query(f"select count(*) from {dbname}.stb1 ")
tdSql.checkData(0,0,25)
tdSql.checkData(0,0,25)
# bug fix for compute
# bug fix for compute
tdSql.query("select c1, abs(c1) -0 ,floor(c1)-0 from ct4 ")
tdSql.query(f"select c1, abs(c1) -0 ,floor(c1)-0 from {dbname}.ct4 ")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,2,None)
tdSql.checkData(0,2,None)
...
@@ -331,7 +331,7 @@ class TDTestCase:
...
@@ -331,7 +331,7 @@ class TDTestCase:
tdSql.checkData(1,1,8.000000000)
tdSql.checkData(1,1,8.000000000)
tdSql.checkData(1,2,8.000000000)
tdSql.checkData(1,2,8.000000000)
tdSql.query(" select c1, abs(c1) -0 ,floor(c1-0.1)-0.1 from ct4")
tdSql.query(f"select c1, abs(c1) -0 ,floor(c1-0.1)-0.1 from {dbname}.ct4")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,2,None)
tdSql.checkData(0,2,None)
...
@@ -339,9 +339,8 @@ class TDTestCase:
...
@@ -339,9 +339,8 @@ class TDTestCase:
tdSql.checkData(1,1,8.000000000)
tdSql.checkData(1,1,8.000000000)
tdSql.checkData(1,2,6.900000000)
tdSql.checkData(1,2,6.900000000)
defabs_func_filter(self):
defabs_func_filter(self,dbname=DBNAME):
tdSql.execute("use db")
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1>5 ")
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>5 ")
tdSql.checkRows(3)
tdSql.checkRows(3)
tdSql.checkData(0,0,8)
tdSql.checkData(0,0,8)
tdSql.checkData(0,1,8.000000000)
tdSql.checkData(0,1,8.000000000)
...
@@ -349,7 +348,7 @@ class TDTestCase:
...
@@ -349,7 +348,7 @@ class TDTestCase:
tdSql.checkData(0,3,7.900000000)
tdSql.checkData(0,3,7.900000000)
tdSql.checkData(0,4,3.000000000)
tdSql.checkData(0,4,3.000000000)
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ")
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
tdSql.checkRows(1)
tdSql.checkRows(1)
tdSql.checkData(0,0,5)
tdSql.checkData(0,0,5)
tdSql.checkData(0,1,5.000000000)
tdSql.checkData(0,1,5.000000000)
...
@@ -357,7 +356,7 @@ class TDTestCase:
...
@@ -357,7 +356,7 @@ class TDTestCase:
tdSql.checkData(0,3,4.900000000)
tdSql.checkData(0,3,4.900000000)
tdSql.checkData(0,4,2.000000000)
tdSql.checkData(0,4,2.000000000)
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ")
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
tdSql.checkRows(1)
tdSql.checkRows(1)
tdSql.checkData(0,0,5)
tdSql.checkData(0,0,5)
tdSql.checkData(0,1,5.000000000)
tdSql.checkData(0,1,5.000000000)
...
@@ -365,7 +364,7 @@ class TDTestCase:
...
@@ -365,7 +364,7 @@ class TDTestCase:
tdSql.checkData(0,3,4.900000000)
tdSql.checkData(0,3,4.900000000)
tdSql.checkData(0,4,2.000000000)
tdSql.checkData(0,4,2.000000000)
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>log(c1,2) limit 1 ")
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1>log(c1,2) limit 1 ")
self.check_result_auto("select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ","select floor(c1), floor(c2) ,floor(c3), floor(c4), floor(c5) ,floor(c6) from sub1_bound")
self.check_result_auto(f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ",f"select floor(c1), floor(c2) ,floor(c3), floor(c4), floor(c5) ,floor(c6) from {dbname}.sub1_bound")
self.check_result_auto("select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ","select floor(c1), floor(c2) ,floor(c3), floor(c3), floor(c2) ,floor(c1) from sub1_bound")
self.check_result_auto(f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ",f"select floor(c1), floor(c2) ,floor(c3), floor(c3), floor(c2) ,floor(c1) from {dbname}.sub1_bound")
self.check_result_auto("select floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(c1)))))))))) nest_col_func from sub1_bound;","select floor(c1) from sub1_bound")
self.check_result_auto(f"select floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(c1)))))))))) nest_col_func from {dbname}.sub1_bound;",f"select floor(c1) from {dbname}.sub1_bound")
self.check_result_auto(" select c5 from stb1 order by ts ","select floor(c5) from stb1 order by ts")
self.check_result_auto(f"select c5 from {dbname}.stb1 order by ts ",f"select floor(c5) from {dbname}.stb1 order by ts")
self.check_result_auto(" select c5 from stb1 order by tbname ","select floor(c5) from stb1 order by tbname")
self.check_result_auto(f"select c5 from {dbname}.stb1 order by tbname ",f"select floor(c5) from {dbname}.stb1 order by tbname")
self.check_result_auto(" select c5 from stb1 where c1 > 0 order by tbname ","select floor(c5) from stb1 where c1 > 0 order by tbname")
self.check_result_auto(f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname ",f"select floor(c5) from {dbname}.stb1 where c1 > 0 order by tbname")
self.check_result_auto(" select c5 from stb1 where c1 > 0 order by tbname ","select floor(c5) from stb1 where c1 > 0 order by tbname")
self.check_result_auto(f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname ",f"select floor(c5) from {dbname}.stb1 where c1 > 0 order by tbname")
self.check_result_auto(" select t1,c5 from stb1 order by ts ","select floor(t1), floor(c5) from stb1 order by ts")
self.check_result_auto(f"select t1,c5 from {dbname}.stb1 order by ts ",f"select floor(t1), floor(c5) from {dbname}.stb1 order by ts")
self.check_result_auto(" select t1,c5 from stb1 order by tbname ","select floor(t1) ,floor(c5) from stb1 order by tbname")
self.check_result_auto(f"select t1,c5 from {dbname}.stb1 order by tbname ",f"select floor(t1) ,floor(c5) from {dbname}.stb1 order by tbname")
self.check_result_auto(" select t1,c5 from stb1 where c1 > 0 order by tbname ","select floor(t1) ,floor(c5) from stb1 where c1 > 0 order by tbname")
self.check_result_auto(f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname ",f"select floor(t1) ,floor(c5) from {dbname}.stb1 where c1 > 0 order by tbname")
self.check_result_auto(" select t1,c5 from stb1 where c1 > 0 order by tbname ","select floor(t1) , floor(c5) from stb1 where c1 > 0 order by tbname")
self.check_result_auto(f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname ",f"select floor(t1) , floor(c5) from {dbname}.stb1 where c1 > 0 order by tbname")
tdSql.execute(f"create stable {dbname}.st2 (ts timestamp , num int) tags(ind int)")
tdSql.execute(" create table ttb1 using st2 tags(1)")
tdSql.execute(f"create table {dbname}.ttb1 using {dbname}.st2 tags(1)")
tdSql.execute(" create table ttb2 using st2 tags(2)")
tdSql.execute(f"create table {dbname}.ttb2 using {dbname}.st2 tags(2)")
start_ts=1622369635000# 2021-05-30 18:13:55
start_ts=1622369635000# 2021-05-30 18:13:55
foriinrange(10):
foriinrange(10):
ts_value=start_ts+i*1000
ts_value=start_ts+i*1000
tdSql.execute(f" insert into tb1 values({ts_value} , {i})")
tdSql.execute(f"insert into {dbname}.tb1 values({ts_value} , {i})")
tdSql.execute(f" insert into tb2 values({ts_value} , {i})")
tdSql.execute(f"insert into {dbname}.tb2 values({ts_value} , {i})")
tdSql.execute(f" insert into ttb1 values({ts_value} , {i})")
tdSql.execute(f"insert into {dbname}.ttb1 values({ts_value} , {i})")
tdSql.execute(f" insert into ttb2 values({ts_value} , {i})")
tdSql.execute(f"insert into {dbname}.ttb2 values({ts_value} , {i})")
tdSql.query("select stateduration(tb1.num,'GT',1,1s) from tb1, tb2 where tb1.ts=tb2.ts ")
tdSql.query(f"select stateduration(tb1.num,'GT',1,1s) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts ")
tdSql.checkRows(10)
tdSql.checkRows(10)
tdSql.checkData(0,0,-1)
tdSql.checkData(0,0,-1)
tdSql.checkData(1,0,-1)
tdSql.checkData(1,0,-1)
tdSql.checkData(2,0,0)
tdSql.checkData(2,0,0)
tdSql.checkData(9,0,7)
tdSql.checkData(9,0,7)
tdSql.query("select stateduration(tb1.num,'GT',1,1s) from tb1, tb2 where tb1.ts=tb2.ts union all select stateduration(tb2.num,'GT',1,1s) from tb1, tb2 where tb1.ts=tb2.ts ")
tdSql.query(f"select stateduration(tb1.num,'GT',1,1s) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts union all select stateduration(tb2.num,'GT',1,1s) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts ")
tdSql.checkRows(20)
tdSql.checkRows(20)
# nest query
# nest query
# tdSql.query("select unique(c1) from (select c1 from ct1)")
# tdSql.query(f"select unique(c1) from (select c1 from {dbname}.ct1)")
tdSql.query("select c1 from (select stateduration(c1,'GT',1,1s) c1 from t1)")
tdSql.query(f"select c1 from (select stateduration(c1,'GT',1,1s) c1 from {dbname}.t1)")
tdSql.checkRows(12)
tdSql.checkRows(12)
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,-1)
tdSql.checkData(1,0,-1)
tdSql.checkData(2,0,0)
tdSql.checkData(2,0,0)
tdSql.checkData(10,0,63072035)
tdSql.checkData(10,0,63072035)
tdSql.query("select sum(c1) from (select stateduration(c1,'GT',1,1d) c1 from t1)")
tdSql.query(f"select sum(c1) from (select stateduration(c1,'GT',1,1d) c1 from {dbname}.t1)")
tdSql.checkRows(1)
tdSql.checkRows(1)
tdSql.checkData(0,0,2893)
tdSql.checkData(0,0,2893)
tdSql.query("select sum(c1) from (select distinct(c1) c1 from ct1) union all select sum(c1) from (select stateduration(c1,'GT',1,1s) c1 from ct1)")
tdSql.query(f"select sum(c1) from (select distinct(c1) c1 from {dbname}.ct1) union all select sum(c1) from (select stateduration(c1,'GT',1,1s) c1 from {dbname}.ct1)")
tdSql.checkRows(2)
tdSql.checkRows(2)
tdSql.query("select 1-abs(c1) from (select stateduration(c1,'GT',1,1s) c1 from t1)")
tdSql.query(f"select 1-abs(c1) from (select stateduration(c1,'GT',1,1s) c1 from {dbname}.t1)")
tdSql.checkRows(12)
tdSql.checkRows(12)
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,0.000000000)
tdSql.checkData(1,0,0.000000000)
tdSql.checkData(3,0,-86404.000000000)
tdSql.checkData(3,0,-86404.000000000)
tdSql.query("select stateduration(abs(c1) ,'GT',1,1s) from t1")
tdSql.query(f"select stateduration(abs(c1) ,'GT',1,1s) from {dbname}.t1")
tdSql.checkRows(12)
tdSql.checkRows(12)
tdSql.query("select stateduration(c1+2 ,'GT',1,1s) from t1")
tdSql.query(f"select stateduration(c1+2 ,'GT',1,1s) from {dbname}.t1")
tdSql.checkRows(12)
tdSql.checkRows(12)
# bug for stable
# bug for stable
#partition by tbname
#partition by tbname
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.query(f"select unique(c1) from {dbname}.stb1 partition by tbname ")
# tdSql.checkRows(21)
# tdSql.checkRows(21)
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.query(f"select unique(c1) from {dbname}.stb1 partition by tbname ")
# tdSql.checkRows(21)
# tdSql.checkRows(21)
# group by
# group by
tdSql.error("select stateduration(c1,'GT',1,1s) from ct1 group by c1")
tdSql.error(f"select stateduration(c1,'GT',1,1s) from {dbname}.ct1 group by c1")
tdSql.error("select stateduration(c1,'GT',1,1s) from ct1 group by tbname")
tdSql.error(f"select stateduration(c1,'GT',1,1s) from {dbname}.ct1 group by tbname")
# super table
# super table
defcheck_unit_time(self):
defcheck_unit_time(self,dbname=DBNAME):
tdSql.execute(" use db ")
tdSql.error(f"select stateduration(c1,'GT',1,1b) from {dbname}.ct1")
tdSql.error("select stateduration(c1,'GT',1,1b) from ct1")
tdSql.error(f"select stateduration(c1,'GT',1,1u) from {dbname}.ct1")
tdSql.error("select stateduration(c1,'GT',1,1u) from ct1")
tdSql.error(f"select stateduration(c1,'GT',1,1000s) from {dbname}.t1")
tdSql.error("select stateduration(c1,'GT',1,1000s) from t1")
tdSql.query(f"select stateduration(c1,'GT',1,1s) from {dbname}.t1")
tdSql.query("select stateduration(c1,'GT',1,1s) from t1")
tdSql.checkData(10,0,63072035)
tdSql.checkData(10,0,63072035)
tdSql.query("select stateduration(c1,'GT',1,1m) from t1")
tdSql.query(f"select stateduration(c1,'GT',1,1m) from {dbname}.t1")
tdSql.checkData(10,0,int(63072035/60))
tdSql.checkData(10,0,int(63072035/60))
tdSql.query("select stateduration(c1,'GT',1,1h) from t1")
tdSql.query(f"select stateduration(c1,'GT',1,1h) from {dbname}.t1")
tdSql.checkData(10,0,int(63072035/60/60))
tdSql.checkData(10,0,int(63072035/60/60))
tdSql.query("select stateduration(c1,'GT',1,1d) from t1")
tdSql.query(f"select stateduration(c1,'GT',1,1d) from {dbname}.t1")
tdSql.checkData(10,0,int(63072035/60/24/60))
tdSql.checkData(10,0,int(63072035/60/24/60))
tdSql.query("select stateduration(c1,'GT',1,1w) from t1")
tdSql.query(f"select stateduration(c1,'GT',1,1w) from {dbname}.t1")