fix case
This commit is contained in:
parent
6d717b450e
commit
acc27d46e9
|
@ -217,9 +217,17 @@ class TDSql:
|
|||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
return
|
||||
elif isinstance(data, float) and abs(self.queryResult[row][col] - data) <= 0.000001:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
elif isinstance(data, float):
|
||||
if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
else:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
|
||||
tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args)
|
||||
return
|
||||
else:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
|
|
|
@ -10,13 +10,13 @@ import random
|
|||
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143,
|
||||
"jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143,
|
||||
"wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143}
|
||||
# updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143,
|
||||
# "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143,
|
||||
# "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143}
|
||||
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
self.tb_nums = 10
|
||||
self.row_nums = 20
|
||||
self.ts = 1434938400000
|
||||
|
@ -24,14 +24,17 @@ class TDTestCase:
|
|||
|
||||
def insert_datas_and_check_abs(self ,tbnums , rownums , time_step ):
|
||||
tdLog.info(" prepare datas for auto check abs function ")
|
||||
dbname = "test"
|
||||
stbname = f"{dbname}.stb"
|
||||
ctbname_pre = f"{dbname}.sub_tb_"
|
||||
|
||||
tdSql.execute(" create database test ")
|
||||
tdSql.execute(" use test ")
|
||||
tdSql.execute(" create stable stb (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,\
|
||||
tdSql.execute(f" create database {dbname} ")
|
||||
tdSql.execute(f" use {dbname} ")
|
||||
tdSql.execute(f" create stable {stbname} (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,\
|
||||
c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)")
|
||||
for tbnum in range(tbnums):
|
||||
tbname = "sub_tb_%d"%tbnum
|
||||
tdSql.execute(" create table %s using stb tags(%d) "%(tbname , tbnum))
|
||||
tbname = f"{ctbname_pre}{tbnum}"
|
||||
tdSql.execute(f" create table {tbname} using {stbname} tags({tbnum}) ")
|
||||
|
||||
ts = self.ts
|
||||
for row in range(rownums):
|
||||
|
@ -48,8 +51,8 @@ class TDTestCase:
|
|||
c10 = ts
|
||||
tdSql.execute(f" insert into {tbname} values ({ts},{c1},{c2},{c3},{c4},{c5},{c6},{c7},{c8},{c9},{c10})")
|
||||
|
||||
tdSql.execute("use test")
|
||||
tbnames = ["stb", "sub_tb_1"]
|
||||
tdSql.execute(f"use {dbname}")
|
||||
tbnames = [f"{stbname}", f"{ctbname_pre}1"]
|
||||
support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"]
|
||||
for tbname in tbnames:
|
||||
tdSql.query("desc {}".format(tbname))
|
||||
|
@ -62,48 +65,48 @@ class TDTestCase:
|
|||
self.check_result_auto(origin_sql , abs_sql)
|
||||
|
||||
|
||||
def prepare_datas(self):
|
||||
def prepare_datas(self, dbname="db"):
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -119,53 +122,53 @@ class TDTestCase:
|
|||
'''
|
||||
)
|
||||
|
||||
def prepare_tag_datas(self):
|
||||
def prepare_tag_datas(self, dbname="testdb"):
|
||||
# prepare datas
|
||||
tdSql.execute(
|
||||
"create database if not exists testdb keep 3650 duration 1000")
|
||||
f"create database if not exists {dbname} keep 3650 duration 1000")
|
||||
tdSql.execute(" use testdb ")
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(
|
||||
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||
f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -213,43 +216,45 @@ class TDTestCase:
|
|||
"abs value check pass , it work as expected ,sql is \"%s\" " % abs_query)
|
||||
|
||||
def test_errors(self):
|
||||
tdSql.execute("use testdb")
|
||||
dbname = "testdb"
|
||||
tdSql.execute(f"use {dbname}")
|
||||
error_sql_lists = [
|
||||
"select abs from t1",
|
||||
"select abs(-+--+c1) from t1",
|
||||
# "select +-abs(c1) from t1",
|
||||
# "select ++-abs(c1) from t1",
|
||||
# "select ++--abs(c1) from t1",
|
||||
# "select - -abs(c1)*0 from t1",
|
||||
# "select abs(tbname+1) from t1 ",
|
||||
"select abs(123--123)==1 from t1",
|
||||
"select abs(c1) as 'd1' from t1",
|
||||
"select abs(c1 ,c2 ) from t1",
|
||||
"select abs(c1 ,NULL) from t1",
|
||||
"select abs(,) from t1;",
|
||||
"select abs(abs(c1) ab from t1)",
|
||||
"select abs(c1) as int from t1",
|
||||
"select abs from stb1",
|
||||
# "select abs(-+--+c1) from stb1",
|
||||
# "select +-abs(c1) from stb1",
|
||||
# "select ++-abs(c1) from stb1",
|
||||
# "select ++--abs(c1) from stb1",
|
||||
# "select - -abs(c1)*0 from stb1",
|
||||
# "select abs(tbname+1) from stb1 ",
|
||||
"select abs(123--123)==1 from stb1",
|
||||
"select abs(c1) as 'd1' from stb1",
|
||||
"select abs(c1 ,c2 ) from stb1",
|
||||
"select abs(c1 ,NULL) from stb1",
|
||||
"select abs(,) from stb1;",
|
||||
"select abs(abs(c1) ab from stb1)",
|
||||
"select abs(c1) as int from stb1"
|
||||
f"select abs from {dbname}.t1",
|
||||
f"select abs(-+--+c1) from {dbname}.t1",
|
||||
# f"select +-abs(c1) from {dbname}.t1",
|
||||
# f"select ++-abs(c1) from {dbname}.t1",
|
||||
# f"select ++--abs(c1) from {dbname}.t1",
|
||||
# f"select - -abs(c1)*0 from {dbname}.t1",
|
||||
# f"select abs(tbname+1) from {dbname}.t1 ",
|
||||
f"select abs(123--123)==1 from {dbname}.t1",
|
||||
f"select abs(c1) as 'd1' from {dbname}.t1",
|
||||
f"select abs(c1 ,c2 ) from {dbname}.t1",
|
||||
f"select abs(c1 ,NULL) from {dbname}.t1",
|
||||
f"select abs(,) from {dbname}.t1;",
|
||||
f"select abs(abs(c1) ab from {dbname}.t1)",
|
||||
f"select abs(c1) as int from {dbname}.t1",
|
||||
f"select abs from {dbname}.stb1",
|
||||
# f"select abs(-+--+c1) from {dbname}.stb1",
|
||||
# f"select +-abs(c1) from {dbname}.stb1",
|
||||
# f"select ++-abs(c1) from {dbname}.stb1",
|
||||
# f"select ++--abs(c1) from {dbname}.stb1",
|
||||
# f"select - -abs(c1)*0 from {dbname}.stb1",
|
||||
# f"select abs(tbname+1) from {dbname}.stb1 ",
|
||||
f"select abs(123--123)==1 from {dbname}.stb1",
|
||||
f"select abs(c1) as 'd1' from {dbname}.stb1",
|
||||
f"select abs(c1 ,c2 ) from {dbname}.stb1",
|
||||
f"select abs(c1 ,NULL) from {dbname}.stb1",
|
||||
f"select abs(,) from {dbname}.stb1;",
|
||||
f"select abs(abs(c1) ab from {dbname}.stb1)",
|
||||
f"select abs(c1) as int from {dbname}.stb1"
|
||||
]
|
||||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
def support_types(self):
|
||||
tdSql.execute("use testdb")
|
||||
tbnames = ["stb1", "t1", "ct1", "ct2"]
|
||||
dbname = "testdb"
|
||||
tdSql.execute(f"use {dbname}")
|
||||
tbnames = [f"{dbname}.stb1", f"{dbname}.t1", f"{dbname}.ct1", f"{dbname}.ct2"]
|
||||
support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"]
|
||||
for tbname in tbnames:
|
||||
tdSql.query("desc {}".format(tbname))
|
||||
|
@ -262,96 +267,96 @@ class TDTestCase:
|
|||
else:
|
||||
tdSql.error(abs_sql)
|
||||
|
||||
def basic_abs_function(self):
|
||||
def basic_abs_function(self, dbname="db"):
|
||||
|
||||
# basic query
|
||||
tdSql.query("select c1 from ct3")
|
||||
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select c1 from t1")
|
||||
tdSql.query(f"select c1 from {dbname}.t1")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select c1 from stb1")
|
||||
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
# used for empty table , ct3 is empty
|
||||
tdSql.query("select abs(c1) from ct3")
|
||||
tdSql.query(f"select abs(c1) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c2) from ct3")
|
||||
tdSql.query(f"select abs(c2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c3) from ct3")
|
||||
tdSql.query(f"select abs(c3) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c4) from ct3")
|
||||
tdSql.query(f"select abs(c4) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c5) from ct3")
|
||||
tdSql.query(f"select abs(c5) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c6) from ct3")
|
||||
tdSql.query(f"select abs(c6) from {dbname}.ct3")
|
||||
|
||||
# used for regular table
|
||||
tdSql.query("select abs(c1) from t1")
|
||||
tdSql.query(f"select abs(c1) from {dbname}.t1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(3, 0, 3)
|
||||
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(3, 3, 33)
|
||||
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(3, 4, 33)
|
||||
tdSql.checkData(5, 5, None)
|
||||
|
||||
self.check_result_auto("select c1, c2, c3 , c4, c5 from t1",
|
||||
"select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from t1")
|
||||
self.check_result_auto(f"select c1, c2, c3 , c4, c5 from {dbname}.t1",
|
||||
f"select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from {dbname}.t1")
|
||||
|
||||
# used for sub table
|
||||
tdSql.query("select abs(c1) from ct1")
|
||||
tdSql.query(f"select abs(c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(1, 0, 7)
|
||||
tdSql.checkData(3, 0, 5)
|
||||
tdSql.checkData(5, 0, 4)
|
||||
|
||||
tdSql.query("select abs(c1) from ct1")
|
||||
self.check_result_auto("select c1, c2, c3 , c4, c5 from ct1",
|
||||
"select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from ct1")
|
||||
tdSql.query(f"select abs(c1) from {dbname}.ct1")
|
||||
self.check_result_auto(f"select c1, c2, c3 , c4, c5 from {dbname}.ct1",
|
||||
f"select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from {dbname}.ct1")
|
||||
self.check_result_auto(
|
||||
"select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from ct1;", "select c1 from ct1")
|
||||
f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from {dbname}.ct1;", f"select c1 from {dbname}.ct1")
|
||||
|
||||
# used for stable table
|
||||
|
||||
tdSql.query("select abs(c1) from stb1")
|
||||
tdSql.query(f"select abs(c1) from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
self.check_result_auto("select c1, c2, c3 , c4, c5 from ct4 ",
|
||||
"select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from ct4")
|
||||
self.check_result_auto(f"select c1, c2, c3 , c4, c5 from {dbname}.ct4 ",
|
||||
f"select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from {dbname}.ct4")
|
||||
self.check_result_auto(
|
||||
"select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from ct4;", "select c1 from ct4")
|
||||
f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from {dbname}.ct4;", f"select c1 from {dbname}.ct4")
|
||||
|
||||
# used for not exists table
|
||||
tdSql.error("select abs(c1) from stbbb1")
|
||||
tdSql.error("select abs(c1) from tbname")
|
||||
tdSql.error("select abs(c1) from ct5")
|
||||
tdSql.error(f"select abs(c1) from {dbname}.stbbb1")
|
||||
tdSql.error(f"select abs(c1) from {dbname}.tbname")
|
||||
tdSql.error(f"select abs(c1) from {dbname}.ct5")
|
||||
|
||||
# mix with common col
|
||||
tdSql.query("select c1, abs(c1) from ct1")
|
||||
tdSql.query(f"select c1, abs(c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(0, 1, 8)
|
||||
tdSql.checkData(4, 0, 0)
|
||||
tdSql.checkData(4, 1, 0)
|
||||
tdSql.query("select c1, abs(c1) from ct4")
|
||||
tdSql.query(f"select c1, abs(c1) from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(4, 0, 5)
|
||||
tdSql.checkData(4, 1, 5)
|
||||
tdSql.checkData(5, 0, None)
|
||||
tdSql.checkData(5, 1, None)
|
||||
tdSql.query("select c1, abs(c1) from ct4 ")
|
||||
tdSql.query(f"select c1, abs(c1) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(4, 0, 5)
|
||||
tdSql.checkData(4, 1, 5)
|
||||
|
||||
# mix with common functions
|
||||
tdSql.query("select c1, abs(c1),c5, floor(c5) from ct4 ")
|
||||
tdSql.query(f"select c1, abs(c1),c5, floor(c5) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -362,33 +367,33 @@ class TDTestCase:
|
|||
tdSql.checkData(3, 2, 6.66000)
|
||||
tdSql.checkData(3, 3, 6.00000)
|
||||
|
||||
tdSql.query("select c1, abs(c1),c5, floor(c5) from stb1 ")
|
||||
tdSql.query(f"select c1, abs(c1),c5, floor(c5) from {dbname}.stb1 ")
|
||||
|
||||
# mix with agg functions , not support
|
||||
tdSql.error("select c1, abs(c1),c5, count(c5) from stb1 ")
|
||||
tdSql.error("select c1, abs(c1),c5, count(c5) from ct1 ")
|
||||
tdSql.error("select abs(c1), count(c5) from stb1 ")
|
||||
tdSql.error("select abs(c1), count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from stb1 ")
|
||||
tdSql.error(f"select c1, abs(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1, abs(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select abs(c1), count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select abs(c1), count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||
|
||||
# agg functions mix with agg functions
|
||||
|
||||
tdSql.query("select max(c5), count(c5) from stb1")
|
||||
tdSql.query("select max(c5), count(c5) from ct1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||
|
||||
# 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.query("select count(*) from ct4 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.ct4 ")
|
||||
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.query("select count(*) from stb1 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0, 0, 25)
|
||||
|
||||
# bug fix for compute
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1)-0 from ct4 ")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1)-0 from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -396,7 +401,7 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 8.000000000)
|
||||
|
||||
tdSql.query(" select c1, abs(c1) -0 ,ceil(c1-0.1)-0.1 from ct4")
|
||||
tdSql.query(f" select c1, abs(c1) -0 ,ceil(c1-0.1)-0.1 from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -404,10 +409,10 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 7.900000000)
|
||||
|
||||
def abs_func_filter(self):
|
||||
tdSql.execute("use db")
|
||||
def abs_func_filter(self, dbname="db"):
|
||||
tdSql.execute(f"use {dbname}")
|
||||
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 ")
|
||||
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(3)
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(0, 1, 8.000000000)
|
||||
|
@ -416,7 +421,7 @@ class TDTestCase:
|
|||
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 ")
|
||||
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.checkData(0, 0, 5)
|
||||
tdSql.checkData(0, 1, 5.000000000)
|
||||
|
@ -425,7 +430,7 @@ class TDTestCase:
|
|||
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 ")
|
||||
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.checkData(0, 0, 5)
|
||||
tdSql.checkData(0, 1, 5.000000000)
|
||||
|
@ -434,7 +439,7 @@ class TDTestCase:
|
|||
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 ")
|
||||
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 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(0, 1, 88888)
|
||||
|
@ -448,127 +453,135 @@ class TDTestCase:
|
|||
|
||||
def check_boundary_values(self):
|
||||
|
||||
tdSql.execute("drop database if exists bound_test")
|
||||
tdSql.execute("create database if not exists bound_test")
|
||||
dbname = "bound_test"
|
||||
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname}")
|
||||
time.sleep(3)
|
||||
tdSql.execute("use bound_test")
|
||||
tdSql.execute(f"use {dbname}")
|
||||
tdSql.execute(
|
||||
"create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
)
|
||||
tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )')
|
||||
tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )')
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.error(
|
||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
self.check_result_auto("select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ",
|
||||
"select abs(c1), abs(c2) ,abs(c3), abs(c4), abs(c5) ,abs(c6) from sub1_bound")
|
||||
self.check_result_auto("select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ",
|
||||
"select abs(c1), abs(c2) ,abs(c3), abs(c3), abs(c2) ,abs(c1) from sub1_bound")
|
||||
self.check_result_auto(f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ",
|
||||
f"select abs(c1), abs(c2) ,abs(c3), abs(c4), abs(c5) ,abs(c6) from {dbname}.sub1_bound")
|
||||
self.check_result_auto(f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ",
|
||||
f"select abs(c1), abs(c2) ,abs(c3), abs(c3), abs(c2) ,abs(c1) from {dbname}.sub1_bound")
|
||||
self.check_result_auto(
|
||||
"select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from sub1_bound;", "select abs(c1) from sub1_bound")
|
||||
f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from {dbname}.sub1_bound;", f"select abs(c1) from {dbname}.sub1_bound")
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query(
|
||||
"select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from sub1_bound ")
|
||||
f"select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0, 0, 2147483647)
|
||||
tdSql.checkData(0, 1, 9223372036854775807)
|
||||
tdSql.checkData(0, 2, 32767)
|
||||
tdSql.checkData(0, 3, 127)
|
||||
tdSql.checkData(0, 4, 339999995214436424907732413799364296704.00000)
|
||||
tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
# tdSql.checkData(0, 4, 339999995214436424907732413799364296704.00000)
|
||||
tdSql.checkData(0, 4, 3.4E+38)
|
||||
# tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
tdSql.checkData(0, 5, 1.7E+308)
|
||||
tdSql.checkData(1, 0, 2147483647)
|
||||
tdSql.checkData(1, 1, 9223372036854775807)
|
||||
tdSql.checkData(1, 2, 32767)
|
||||
tdSql.checkData(1, 3, 127)
|
||||
tdSql.checkData(1, 4, 339999995214436424907732413799364296704.00000)
|
||||
tdSql.checkData(1, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
# tdSql.checkData(1, 4, 339999995214436424907732413799364296704.00000)
|
||||
tdSql.checkData(1, 4, 3.4E+38)
|
||||
# tdSql.checkData(1, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
tdSql.checkData(1, 5, 1.7E+308)
|
||||
tdSql.checkData(3, 0, 2147483646)
|
||||
tdSql.checkData(3, 1, 9223372036854775806)
|
||||
tdSql.checkData(3, 2, 32766)
|
||||
tdSql.checkData(3, 3, 126)
|
||||
tdSql.checkData(3, 4, 339999995214436424907732413799364296704.00000)
|
||||
tdSql.checkData(3, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
# tdSql.checkData(3, 4, 339999995214436424907732413799364296704.00000)
|
||||
tdSql.checkData(3, 4, 3.4E+38)
|
||||
# tdSql.checkData(3, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
tdSql.checkData(3, 5, 1.7E+308)
|
||||
|
||||
# check + - * / in functions
|
||||
tdSql.query(
|
||||
"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ")
|
||||
f"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0, 0, 2147483648.000000000)
|
||||
tdSql.checkData(0, 1, 9223372036854775807)
|
||||
tdSql.checkData(0, 2, 32767.000000000)
|
||||
tdSql.checkData(0, 3, 63.500000000)
|
||||
tdSql.checkData(
|
||||
0, 4, 169999997607218212453866206899682148352.000000000)
|
||||
tdSql.checkData(0, 4, 169999997607218212453866206899682148352.000000000)
|
||||
tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
|
||||
tdSql.checkData(1, 0, 2147483646.000000000)
|
||||
tdSql.checkData(1, 1, 9223372036854775808.000000000)
|
||||
tdSql.checkData(1, 2, 32767.000000000)
|
||||
tdSql.checkData(1, 3, 63.500000000)
|
||||
tdSql.checkData(
|
||||
1, 4, 169999997607218212453866206899682148352.000000000)
|
||||
tdSql.checkData(1, 4, 169999997607218212453866206899682148352.000000000)
|
||||
|
||||
self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound",
|
||||
"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ")
|
||||
self.check_result_auto(f"select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from {dbname}.sub1_bound",
|
||||
f"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from {dbname}.sub1_bound ")
|
||||
|
||||
def test_tag_compute_for_scalar_function(self):
|
||||
dbname = "testdb"
|
||||
|
||||
tdSql.execute("use testdb")
|
||||
tdSql.execute(f"use {dbname}")
|
||||
|
||||
self.check_result_auto("select c1, t2, t3 , t4, t5 from ct4 ",
|
||||
"select (c1), abs(t2) ,abs(t3), abs(t4), abs(t5) from ct4")
|
||||
self.check_result_auto("select c1+2, t2+2, t3 , t4, t5 from ct4 ",
|
||||
"select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from ct4")
|
||||
self.check_result_auto("select c1+2, t2+2, t3 , t4, t5 from stb1 order by t1 ",
|
||||
"select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from stb1 order by t1")
|
||||
self.check_result_auto(f"select c1, t2, t3 , t4, t5 from {dbname}.ct4 ",
|
||||
f"select (c1), abs(t2) ,abs(t3), abs(t4), abs(t5) from {dbname}.ct4")
|
||||
self.check_result_auto(f"select c1+2, t2+2, t3 , t4, t5 from {dbname}.ct4 ",
|
||||
f"select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from {dbname}.ct4")
|
||||
self.check_result_auto(f"select c1+2, t2+2, t3 , t4, t5 from {dbname}.stb1 order by t1 ",
|
||||
f"select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from {dbname}.stb1 order by t1")
|
||||
|
||||
# bug need fix
|
||||
|
||||
# tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ") # taosd crash
|
||||
tdSql.query("select c1 ,t1 from stb1 where t1 =0 ")
|
||||
tdSql.query(f"select c1 ,t1 from {dbname}.stb1 where t1 =0 ")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.query("select t1 from stb1 where t1 >0 ")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where t1 >0 ")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select t1 from stb1 where t1 =3 ")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where t1 =3 ")
|
||||
tdSql.checkRows(12)
|
||||
# tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)")
|
||||
# tdSql.query(f"select sum(t1) from (select c1 ,t1 from {dbname}.stb1)")
|
||||
# tdSql.checkData(0,0,61)
|
||||
# tdSql.query("select distinct(c1) ,t1 from stb1")
|
||||
# tdSql.query(f"select distinct(c1) ,t1 from {dbname}.stb1")
|
||||
# tdSql.checkRows(20)
|
||||
tdSql.query("select max(t2) , t1 ,c1, t2 from stb1")
|
||||
tdSql.query(f"select max(t2) , t1 ,c1, t2 from {dbname}.stb1")
|
||||
tdSql.checkData(0,3,33333)
|
||||
|
||||
# tag filter with abs function
|
||||
tdSql.query("select t1 from stb1 where abs(t1)=1")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where abs(t1)=1")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select t1 from stb1 where abs(c1+t1)=1")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where abs(c1+t1)=1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
||||
tdSql.query(
|
||||
"select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1")
|
||||
f"select abs(c1+t1)*t1 from {dbname}.stb1 where abs(c1)/floor(abs(ceil(t1))) ==1")
|
||||
|
||||
def support_super_table_test(self):
|
||||
tdSql.execute(" use testdb ")
|
||||
self.check_result_auto( " select c1 from stb1 order by ts " , "select abs(c1) from stb1 order by ts" )
|
||||
self.check_result_auto( " select c1 from stb1 order by tbname " , "select abs(c1) from stb1 order by tbname" )
|
||||
self.check_result_auto( " select c1 from stb1 where c1 > 0 order by tbname " , "select abs(c1) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( " select c1 from stb1 where c1 > 0 order by tbname " , "select abs(c1) from stb1 where c1 > 0 order by tbname" )
|
||||
dbname = "testdb"
|
||||
tdSql.execute(f" use {dbname} ")
|
||||
self.check_result_auto( f" select c1 from {dbname}.stb1 order by ts " , f"select abs(c1) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto( f" select c1 from {dbname}.stb1 order by tbname " , f"select abs(c1) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto( f" select c1 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select abs(c1) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f" select c1 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select abs(c1) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto( " select t1,c1 from stb1 order by ts " , "select t1, abs(c1) from stb1 order by ts" )
|
||||
self.check_result_auto( " select t2,c1 from stb1 order by tbname " , "select t2 ,abs(c1) from stb1 order by tbname" )
|
||||
self.check_result_auto( " select t3,c1 from stb1 where c1 > 0 order by tbname " , "select t3 ,abs(c1) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( " select t4,c1 from stb1 where c1 > 0 order by tbname " , "select t4 , abs(c1) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f" select t1,c1 from {dbname}.stb1 order by ts " , f"select t1, abs(c1) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto( f" select t2,c1 from {dbname}.stb1 order by tbname " , f"select t2 ,abs(c1) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto( f" select t3,c1 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select t3 ,abs(c1) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f" select t4,c1 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select t4 , abs(c1) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -10,28 +10,31 @@ import random
|
|||
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143,
|
||||
"jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143,
|
||||
"wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143}
|
||||
# updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143,
|
||||
# "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143,
|
||||
# "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143}
|
||||
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
self.tb_nums = 10
|
||||
self.row_nums = 20
|
||||
self.ts = 1434938400000
|
||||
self.time_step = 1000
|
||||
|
||||
def insert_datas_and_check_abs(self ,tbnums , rownums , time_step ):
|
||||
dbname = "test"
|
||||
stb = f"{dbname}.stb"
|
||||
ctb_pre = f"{dbname}.sub_tb_"
|
||||
tdLog.info(" prepare datas for auto check abs function ")
|
||||
|
||||
tdSql.execute(" create database test ")
|
||||
tdSql.execute(" use test ")
|
||||
tdSql.execute(" create stable stb (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,\
|
||||
tdSql.execute(f" create database {dbname} ")
|
||||
tdSql.execute(f" use {dbname} ")
|
||||
tdSql.execute(f" create stable {stb} (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,\
|
||||
c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)")
|
||||
for tbnum in range(tbnums):
|
||||
tbname = "sub_tb_%d"%tbnum
|
||||
tdSql.execute(" create table %s using stb tags(%d) "%(tbname , tbnum))
|
||||
tbname = f"{ctb_pre}{tbnum}"
|
||||
tdSql.execute(f" create table {tbname} using {stb} tags({tbnum}) ")
|
||||
|
||||
ts = self.ts
|
||||
for row in range(rownums):
|
||||
|
@ -49,7 +52,7 @@ class TDTestCase:
|
|||
tdSql.execute(f" insert into {tbname} values ({ts},{c1},{c2},{c3},{c4},{c5},{c6},{c7},{c8},{c9},{c10})")
|
||||
|
||||
tdSql.execute("use test")
|
||||
tbnames = ["stb", "sub_tb_1"]
|
||||
tbnames = [stb, f"{ctb_pre}1"]
|
||||
support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"]
|
||||
for tbname in tbnames:
|
||||
tdSql.query("desc {}".format(tbname))
|
||||
|
@ -64,48 +67,48 @@ class TDTestCase:
|
|||
self.check_function("|",False,tbname,cols[0],cols[1],cols[2])
|
||||
|
||||
|
||||
def prepare_datas(self):
|
||||
def prepare_datas(self, dbname="db"):
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -121,53 +124,53 @@ class TDTestCase:
|
|||
'''
|
||||
)
|
||||
|
||||
def prepare_tag_datas(self):
|
||||
def prepare_tag_datas(self, dbname="testdb"):
|
||||
# prepare datas
|
||||
tdSql.execute(
|
||||
"create database if not exists testdb keep 3650 duration 1000")
|
||||
tdSql.execute(" use testdb ")
|
||||
f"create database if not exists {dbname} keep 3650 duration 1000")
|
||||
tdSql.execute(f" use {dbname} ")
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(
|
||||
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||
f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(
|
||||
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(
|
||||
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -270,88 +273,88 @@ class TDTestCase:
|
|||
for ind , result in enumerate(compute_result):
|
||||
tdSql.checkData(ind,0,result)
|
||||
|
||||
def test_errors(self):
|
||||
tdSql.execute("use testdb")
|
||||
def test_errors(self, dbname="testdb"):
|
||||
tdSql.execute(f"use {dbname}")
|
||||
error_sql_lists = [
|
||||
"select c1&&c2 from t1",
|
||||
"select c1&|c2 from t1",
|
||||
"select c1&(c1=c2) from t1",
|
||||
"select c1&* from t1",
|
||||
"select 123&, from t1",
|
||||
"select 123&\" from t1",
|
||||
"select c1&- from t1;",
|
||||
"select c1&&= from t1)",
|
||||
"select c1&! from t1",
|
||||
"select c1&@ from stb1",
|
||||
"select c1&# from stb1",
|
||||
"select c1&$ from stb1",
|
||||
"select c1&% from stb1",
|
||||
"select c1&() from stb1",
|
||||
f"select c1&&c2 from {dbname}.t1",
|
||||
f"select c1&|c2 from {dbname}.t1",
|
||||
f"select c1&(c1=c2) from {dbname}.t1",
|
||||
f"select c1&* from {dbname}.t1",
|
||||
f"select 123&, from {dbname}.t1",
|
||||
f"select 123&\" from {dbname}.t1",
|
||||
f"select c1&- from {dbname}.t1;",
|
||||
f"select c1&&= from {dbname}.t1)",
|
||||
f"select c1&! from {dbname}.t1",
|
||||
f"select c1&@ from {dbname}.stb1",
|
||||
f"select c1&# from {dbname}.stb1",
|
||||
f"select c1&$ from {dbname}.stb1",
|
||||
f"select c1&% from {dbname}.stb1",
|
||||
f"select c1&() from {dbname}.stb1",
|
||||
]
|
||||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
def basic_query(self):
|
||||
def basic_query(self, dbname="testdb"):
|
||||
# basic query
|
||||
tdSql.query("select c1&c2|c3 from ct1")
|
||||
tdSql.query(f"select c1&c2|c3 from {dbname}.ct1")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.query("select c1 ,c2&c3, c1&c2&c3 from t1")
|
||||
tdSql.query(f"select c1 ,c2&c3, c1&c2&c3 from {dbname}.t1")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select c1 ,c1&c1&c1|c1 from stb1")
|
||||
tdSql.query(f"select c1 ,c1&c1&c1|c1 from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
# used for empty table , ct3 is empty
|
||||
tdSql.query("select abs(c1)&c2&c3 from ct3")
|
||||
tdSql.query(f"select abs(c1)&c2&c3 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c2&c1&c3) from ct3")
|
||||
tdSql.query(f"select abs(c2&c1&c3) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select abs(c3)+c1&c3+c2 from ct3")
|
||||
tdSql.query(f"select abs(c3)+c1&c3+c2 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query("select abs(c1)&c2&c3 from ct4")
|
||||
tdSql.query(f"select abs(c1)&c2&c3 from {dbname}.ct4")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.checkData(0,0,None)
|
||||
tdSql.checkData(1,0,8)
|
||||
tdSql.checkData(10,0,0)
|
||||
tdSql.query("select abs(c2&c1&c3) from ct4")
|
||||
tdSql.query(f"select abs(c2&c1&c3) from {dbname}.ct4")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.checkData(0,0,None)
|
||||
tdSql.checkData(1,0,8)
|
||||
tdSql.checkData(10,0,0)
|
||||
tdSql.query("select (abs(c3)+c1)&(c3+c2) from ct4")
|
||||
tdSql.query(f"select (abs(c3)+c1)&(c3+c2) from {dbname}.ct4")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.checkData(0,0,None)
|
||||
tdSql.checkData(1,0,640)
|
||||
tdSql.checkData(10,0,0)
|
||||
|
||||
# used for regular table
|
||||
tdSql.query("select abs(c1)&c3&c3 from t1")
|
||||
tdSql.query(f"select abs(c1)&c3&c3 from {dbname}.t1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(3, 0, 1)
|
||||
tdSql.checkData(5, 0, None)
|
||||
|
||||
tdSql.query("select abs(c1)&c2|ceil(c3)&c4|floor(c5) from t1")
|
||||
tdSql.query(f"select abs(c1)&c2|ceil(c3)&c4|floor(c5) from {dbname}.t1")
|
||||
tdSql.checkData(1, 0, 11)
|
||||
tdSql.checkData(3, 0, 3)
|
||||
tdSql.checkData(5, 0, 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, 3, 11)
|
||||
tdSql.checkData(3, 3, 3)
|
||||
tdSql.checkData(5, 3, None)
|
||||
|
||||
self.check_function("&",False,"stb1","c1","ceil(c2)","abs(c3)","c4+1")
|
||||
self.check_function("|",False,"stb1","c1","ceil(c2)","abs(c3)","c4+1")
|
||||
self.check_function("&",False,"stb1","c1+c2","ceil(c2)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,"ct4","123","ceil(c2)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,"ct4","123","ceil(t1)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,"ct4","t1+c1","-ceil(t1)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,"stb1","c1","floor(t1)","abs(c1+c2)","t1+1")
|
||||
self.check_function("&",True,"stb1","max(c1)","min(floor(t1))","sum(abs(c1+c2))","last(t1)+1")
|
||||
self.check_function("&",False,"stb1","abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))))","floor(t1)","abs(c1+c2)","t1+1")
|
||||
self.check_function("&",False,f"{dbname}.stb1","c1","ceil(c2)","abs(c3)","c4+1")
|
||||
self.check_function("|",False,f"{dbname}.stb1","c1","ceil(c2)","abs(c3)","c4+1")
|
||||
self.check_function("&",False,f"{dbname}.stb1","c1+c2","ceil(c2)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,f"{dbname}.ct4","123","ceil(c2)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,f"{dbname}.ct4","123","ceil(t1)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,f"{dbname}.ct4","t1+c1","-ceil(t1)","abs(c3+c2)","c4+1")
|
||||
self.check_function("&",False,f"{dbname}.stb1","c1","floor(t1)","abs(c1+c2)","t1+1")
|
||||
self.check_function("&",True,f"{dbname}.stb1","max(c1)","min(floor(t1))","sum(abs(c1+c2))","last(t1)+1")
|
||||
self.check_function("&",False,f"{dbname}.stb1","abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))))","floor(t1)","abs(c1+c2)","t1+1")
|
||||
|
||||
# mix with common col
|
||||
tdSql.query("select c1&abs(c1)&c2&c3 ,c1,c2, t1 from ct1")
|
||||
tdSql.query(f"select c1&abs(c1)&c2&c3 ,c1,c2, t1 from {dbname}.ct1")
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(4, 0, 0)
|
||||
|
@ -360,7 +363,7 @@ class TDTestCase:
|
|||
|
||||
|
||||
# mix with common functions
|
||||
tdSql.query(" select c1&abs(c1)&c2&c3, abs(c1), c5, floor(c5) from ct4 ")
|
||||
tdSql.query(f" select c1&abs(c1)&c2&c3, abs(c1), c5, floor(c5) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -371,28 +374,28 @@ class TDTestCase:
|
|||
tdSql.checkData(3, 2, 6.66000)
|
||||
tdSql.checkData(3, 3, 6.00000)
|
||||
|
||||
tdSql.query("select c1&abs(c1)&c2&c3, abs(c1),c5, floor(c5) from stb1 order by ts ")
|
||||
tdSql.query(f"select c1&abs(c1)&c2&c3, abs(c1),c5, floor(c5) from {dbname}.stb1 order by ts ")
|
||||
tdSql.checkData(3, 0, 2)
|
||||
tdSql.checkData(3, 1, 6)
|
||||
tdSql.checkData(3, 2, 6.66000)
|
||||
tdSql.checkData(3, 3, 6.00000)
|
||||
|
||||
# mix with agg functions , not support
|
||||
tdSql.error("select c1&abs(c1)&c2&c3, abs(c1),c5, count(c5) from stb1 ")
|
||||
tdSql.error("select c1&abs(c1)&c2&c3, abs(c1),c5, count(c5) from ct1 ")
|
||||
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from stb1 ")
|
||||
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from ct1 ")
|
||||
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from ct1 ")
|
||||
tdSql.error("select c1&abs(c1)&c2&c3, count(c5) from stb1 ")
|
||||
tdSql.error(f"select c1&abs(c1)&c2&c3, abs(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1&abs(c1)&c2&c3, abs(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1&abs(c1)&c2&c3, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1&abs(c1)&c2&c3, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1&abs(c1)&c2&c3, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1&abs(c1)&c2&c3, count(c5) from {dbname}.stb1 ")
|
||||
|
||||
# agg functions mix with agg functions
|
||||
|
||||
tdSql.query("select sum(c1&abs(c1)&c2&c3) ,max(c5), count(c5) from stb1")
|
||||
tdSql.query(f"select sum(c1&abs(c1)&c2&c3) ,max(c5), count(c5) from {dbname}.stb1")
|
||||
|
||||
tdSql.query("select max(c1)&max(c2)|first(ts), count(c5) from ct1")
|
||||
tdSql.query(f"select max(c1)&max(c2)|first(ts), count(c5) from {dbname}.ct1")
|
||||
|
||||
# bug fix for compute
|
||||
tdSql.query("select c1&abs(c1)&c2&c3, abs(c1&abs(c1)&c2&c3) -0 ,ceil(c1&abs(c1)&c2&c3)-0 from ct4 ")
|
||||
tdSql.query(f"select c1&abs(c1)&c2&c3, abs(c1&abs(c1)&c2&c3) -0 ,ceil(c1&abs(c1)&c2&c3)-0 from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -400,7 +403,7 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 8.000000000)
|
||||
|
||||
tdSql.query(" select c1&c2|c3, abs(c1&c2|c3) -0 ,ceil(c1&c2|c3-0.1)-0.1 from ct4")
|
||||
tdSql.query(f" select c1&c2|c3, abs(c1&c2|c3) -0 ,ceil(c1&c2|c3-0.1)-0.1 from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -411,38 +414,38 @@ class TDTestCase:
|
|||
|
||||
|
||||
|
||||
def check_boundary_values(self):
|
||||
def check_boundary_values(self, dbname="bound_test"):
|
||||
|
||||
tdSql.execute("drop database if exists bound_test")
|
||||
tdSql.execute("create database if not exists bound_test")
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname}")
|
||||
time.sleep(3)
|
||||
tdSql.execute("use bound_test")
|
||||
tdSql.execute(f"use {dbname}")
|
||||
tdSql.execute(
|
||||
"create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
)
|
||||
tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )')
|
||||
tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )')
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.error(
|
||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
self.check_function("&", False , "sub1_bound" ,"c1","c2","c3","c4","c5","c6" )
|
||||
self.check_function("&", False ,"sub1_bound","abs(c1)","abs(c2)","abs(c3)","abs(c4)","abs(c5)","abs(c6)" )
|
||||
self.check_function("&", False ,"stb_bound","123","abs(c2)","t1","abs(c4)","abs(c5)","abs(c6)" )
|
||||
self.check_function("&", False , f"{dbname}.sub1_bound" ,"c1","c2","c3","c4","c5","c6" )
|
||||
self.check_function("&", False , f"{dbname}.sub1_bound","abs(c1)","abs(c2)","abs(c3)","abs(c4)","abs(c5)","abs(c6)" )
|
||||
self.check_function("&", False , f"{dbname}.stb_bound","123","abs(c2)","t1","abs(c4)","abs(c5)","abs(c6)" )
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query(
|
||||
"select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from sub1_bound ")
|
||||
f"select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0, 0, 2147483647)
|
||||
tdSql.checkData(0, 1, 9223372036854775807)
|
||||
tdSql.checkData(0, 2, 32767)
|
||||
|
@ -463,10 +466,10 @@ class TDTestCase:
|
|||
tdSql.checkData(3, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000)
|
||||
|
||||
# check + - * / in functions
|
||||
self.check_function("&", False ,"stb_bound","abs(c1+1)","abs(c2)","t1","abs(c3*1)","abs(c5)/2","abs(c6)" )
|
||||
self.check_function("&", False , f"{dbname}.stb_bound","abs(c1+1)","abs(c2)","t1","abs(c3*1)","abs(c5)/2","abs(c6)" )
|
||||
|
||||
tdSql.query(
|
||||
"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ")
|
||||
f"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0, 0, 2147483648.000000000)
|
||||
tdSql.checkData(0, 1, 9223372036854775807)
|
||||
tdSql.checkData(0, 2, 32767.000000000)
|
||||
|
@ -483,44 +486,44 @@ class TDTestCase:
|
|||
1, 4, 169999997607218212453866206899682148352.000000000)
|
||||
|
||||
|
||||
def test_tag_compute_for_scalar_function(self):
|
||||
def test_tag_compute_for_scalar_function(self, dbname="testdb"):
|
||||
|
||||
tdSql.execute("use testdb")
|
||||
tdSql.execute(f"use {dbname}")
|
||||
|
||||
self.check_function("&", False ,"ct4","123","abs(c1)","t1","abs(t2)","abs(t3)","abs(t4)","t5")
|
||||
self.check_function("&", False ,"ct4","c1+2","abs(t2+2)","t3","abs(t4)","abs(t5)","abs(c1)","t5")
|
||||
self.check_function("&", False , f"{dbname}.ct4","123","abs(c1)","t1","abs(t2)","abs(t3)","abs(t4)","t5")
|
||||
self.check_function("&", False , f"{dbname}.ct4","c1+2","abs(t2+2)","t3","abs(t4)","abs(t5)","abs(c1)","t5")
|
||||
|
||||
tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ")
|
||||
tdSql.query("select c1 ,t1 from stb1 where t1 =0 ")
|
||||
tdSql.query(f" select sum(c1) from {dbname}.stb1 where t1+10 >1; ")
|
||||
tdSql.query(f"select c1 ,t1 from {dbname}.stb1 where t1 =0 ")
|
||||
tdSql.checkRows(13)
|
||||
self.check_function("&", False ,"t1","c1+2","abs(c2)")
|
||||
tdSql.query("select t1 from stb1 where t1 >0 ")
|
||||
self.check_function("&", False , f"{dbname}.t1","c1+2","abs(c2)")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where t1 >0 ")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select t1 from stb1 where t1 =3 ")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where t1 =3 ")
|
||||
tdSql.checkRows(12)
|
||||
# tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)")
|
||||
# tdSql.checkData(0,0,61)
|
||||
# tdSql.query("select distinct(c1) ,t1 from stb1")
|
||||
# tdSql.checkRows(20)
|
||||
tdSql.query("select max(c1) , t1&c2&t2 from stb1;")
|
||||
tdSql.query(f"select max(c1) , t1&c2&t2 from {dbname}.stb1;")
|
||||
tdSql.checkData(0,1,0)
|
||||
|
||||
# tag filter with abs function
|
||||
tdSql.query("select t1 from stb1 where abs(t1)=1")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where abs(t1)=1")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select t1 from stb1 where abs(c1+t1)=1")
|
||||
tdSql.query(f"select t1 from {dbname}.stb1 where abs(c1+t1)=1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
||||
tdSql.query(
|
||||
"select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1")
|
||||
f"select abs(c1+t1)*t1 from {dbname}.stb1 where abs(c1)/floor(abs(ceil(t1))) ==1")
|
||||
|
||||
def support_super_table_test(self):
|
||||
tdSql.execute(" use testdb ")
|
||||
self.check_function("|", False , "stb1" , "c1","c2","c3","c4" )
|
||||
self.check_function("|", False , "stb1" , "c1","c2","abs(c3)","c4","ceil(t1)" )
|
||||
self.check_function("&", False , "stb1" , "c1","c2","abs(c3)","floor(c4)","ceil(t1)" )
|
||||
self.check_function("&", True , "stb1" , "max(c1)","max(c2)","sum(abs(c3))","max(floor(c4))","min(ceil(t1))" )
|
||||
def support_super_table_test(self, dbname="testdb"):
|
||||
tdSql.execute(f" use {dbname} ")
|
||||
self.check_function("|", False , f"{dbname}.stb1" , "c1","c2","c3","c4" )
|
||||
self.check_function("|", False , f"{dbname}.stb1" , "c1","c2","abs(c3)","c4","ceil(t1)" )
|
||||
self.check_function("&", False , f"{dbname}.stb1" , "c1","c2","abs(c3)","floor(c4)","ceil(t1)" )
|
||||
self.check_function("&", True , f"{dbname}.stb1" , "max(c1)","max(c2)","sum(abs(c3))","max(floor(c4))","min(ceil(t1))" )
|
||||
|
||||
|
||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||
|
|
|
@ -20,12 +20,13 @@ from util.sqlset import TDSetSql
|
|||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(),logSql)
|
||||
tdSql.init(conn.cursor(),False)
|
||||
self.rowNum = 10
|
||||
self.ts = 1537146000000
|
||||
self.setsql = TDSetSql()
|
||||
self.ntbname = 'ntb'
|
||||
self.stbname = 'stb'
|
||||
self.dbname = "db"
|
||||
self.ntbname = f"{self.dbname}.ntb"
|
||||
self.stbname = f'{self.dbname}.stb'
|
||||
self.binary_length = 20 # the length of binary for column_dict
|
||||
self.nchar_length = 20 # the length of nchar for column_dict
|
||||
self.column_dict = {
|
||||
|
|
|
@ -9,49 +9,49 @@ from util.cases import *
|
|||
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||
# updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
||||
# "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
||||
# "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||
def init(self, conn, powSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
self.PI =3.1415926
|
||||
|
||||
def prepare_datas(self):
|
||||
def prepare_datas(self, dbname="db"):
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -102,68 +102,68 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.info("acos value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
||||
|
||||
def test_errors(self):
|
||||
def test_errors(self, dbname="db"):
|
||||
error_sql_lists = [
|
||||
"select acos from t1",
|
||||
# "select acos(-+--+c1 ) from t1",
|
||||
# "select +-acos(c1) from t1",
|
||||
# "select ++-acos(c1) from t1",
|
||||
# "select ++--acos(c1) from t1",
|
||||
# "select - -acos(c1)*0 from t1",
|
||||
# "select acos(tbname+1) from t1 ",
|
||||
"select acos(123--123)==1 from t1",
|
||||
"select acos(c1) as 'd1' from t1",
|
||||
"select acos(c1 ,c2) from t1",
|
||||
"select acos(c1 ,NULL ) from t1",
|
||||
"select acos(,) from t1;",
|
||||
"select acos(acos(c1) ab from t1)",
|
||||
"select acos(c1 ) as int from t1",
|
||||
"select acos from stb1",
|
||||
# "select acos(-+--+c1) from stb1",
|
||||
# "select +-acos(c1) from stb1",
|
||||
# "select ++-acos(c1) from stb1",
|
||||
# "select ++--acos(c1) from stb1",
|
||||
# "select - -acos(c1)*0 from stb1",
|
||||
# "select acos(tbname+1) from stb1 ",
|
||||
"select acos(123--123)==1 from stb1",
|
||||
"select acos(c1) as 'd1' from stb1",
|
||||
"select acos(c1 ,c2 ) from stb1",
|
||||
"select acos(c1 ,NULL) from stb1",
|
||||
"select acos(,) from stb1;",
|
||||
"select acos(acos(c1) ab from stb1)",
|
||||
"select acos(c1) as int from stb1"
|
||||
f"select acos from {dbname}.t1",
|
||||
# f"select acos(-+--+c1 ) from {dbname}.t1",
|
||||
# f"select +-acos(c1) from {dbname}.t1",
|
||||
# f"select ++-acos(c1) from {dbname}.t1",
|
||||
# f"select ++--acos(c1) from {dbname}.t1",
|
||||
# f"select - -acos(c1)*0 from {dbname}.t1",
|
||||
# f"select acos(tbname+1) from {dbname}.t1 ",
|
||||
f"select acos(123--123)==1 from {dbname}.t1",
|
||||
f"select acos(c1) as 'd1' from {dbname}.t1",
|
||||
f"select acos(c1 ,c2) from {dbname}.t1",
|
||||
f"select acos(c1 ,NULL ) from {dbname}.t1",
|
||||
f"select acos(,) from {dbname}.t1;",
|
||||
f"select acos(acos(c1) ab from {dbname}.t1)",
|
||||
f"select acos(c1 ) as int from {dbname}.t1",
|
||||
f"select acos from {dbname}.stb1",
|
||||
# f"select acos(-+--+c1) from {dbname}.stb1",
|
||||
# f"select +-acos(c1) from {dbname}.stb1",
|
||||
# f"select ++-acos(c1) from {dbname}.stb1",
|
||||
# f"select ++--acos(c1) from {dbname}.stb1",
|
||||
# f"select - -acos(c1)*0 from {dbname}.stb1",
|
||||
# f"select acos(tbname+1) from {dbname}.stb1 ",
|
||||
f"select acos(123--123)==1 from {dbname}.stb1",
|
||||
f"select acos(c1) as 'd1' from {dbname}.stb1",
|
||||
f"select acos(c1 ,c2 ) from {dbname}.stb1",
|
||||
f"select acos(c1 ,NULL) from {dbname}.stb1",
|
||||
f"select acos(,) from {dbname}.stb1;",
|
||||
f"select acos(acos(c1) ab from {dbname}.stb1)",
|
||||
f"select acos(c1) as int from {dbname}.stb1"
|
||||
]
|
||||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
def support_types(self):
|
||||
def support_types(self, dbname="db"):
|
||||
type_error_sql_lists = [
|
||||
"select acos(ts) from t1" ,
|
||||
"select acos(c7) from t1",
|
||||
"select acos(c8) from t1",
|
||||
"select acos(c9) from t1",
|
||||
"select acos(ts) from ct1" ,
|
||||
"select acos(c7) from ct1",
|
||||
"select acos(c8) from ct1",
|
||||
"select acos(c9) from ct1",
|
||||
"select acos(ts) from ct3" ,
|
||||
"select acos(c7) from ct3",
|
||||
"select acos(c8) from ct3",
|
||||
"select acos(c9) from ct3",
|
||||
"select acos(ts) from ct4" ,
|
||||
"select acos(c7) from ct4",
|
||||
"select acos(c8) from ct4",
|
||||
"select acos(c9) from ct4",
|
||||
"select acos(ts) from stb1" ,
|
||||
"select acos(c7) from stb1",
|
||||
"select acos(c8) from stb1",
|
||||
"select acos(c9) from stb1" ,
|
||||
f"select acos(ts) from {dbname}.t1" ,
|
||||
f"select acos(c7) from {dbname}.t1",
|
||||
f"select acos(c8) from {dbname}.t1",
|
||||
f"select acos(c9) from {dbname}.t1",
|
||||
f"select acos(ts) from {dbname}.ct1" ,
|
||||
f"select acos(c7) from {dbname}.ct1",
|
||||
f"select acos(c8) from {dbname}.ct1",
|
||||
f"select acos(c9) from {dbname}.ct1",
|
||||
f"select acos(ts) from {dbname}.ct3" ,
|
||||
f"select acos(c7) from {dbname}.ct3",
|
||||
f"select acos(c8) from {dbname}.ct3",
|
||||
f"select acos(c9) from {dbname}.ct3",
|
||||
f"select acos(ts) from {dbname}.ct4" ,
|
||||
f"select acos(c7) from {dbname}.ct4",
|
||||
f"select acos(c8) from {dbname}.ct4",
|
||||
f"select acos(c9) from {dbname}.ct4",
|
||||
f"select acos(ts) from {dbname}.stb1" ,
|
||||
f"select acos(c7) from {dbname}.stb1",
|
||||
f"select acos(c8) from {dbname}.stb1",
|
||||
f"select acos(c9) from {dbname}.stb1" ,
|
||||
|
||||
"select acos(ts) from stbbb1" ,
|
||||
"select acos(c7) from stbbb1",
|
||||
f"select acos(ts) from {dbname}.stbbb1" ,
|
||||
f"select acos(c7) from {dbname}.stbbb1",
|
||||
|
||||
"select acos(ts) from tbname",
|
||||
"select acos(c9) from tbname"
|
||||
f"select acos(ts) from {dbname}.tbname",
|
||||
f"select acos(c9) from {dbname}.tbname"
|
||||
|
||||
]
|
||||
|
||||
|
@ -172,103 +172,103 @@ class TDTestCase:
|
|||
|
||||
|
||||
type_sql_lists = [
|
||||
"select acos(c1) from t1",
|
||||
"select acos(c2) from t1",
|
||||
"select acos(c3) from t1",
|
||||
"select acos(c4) from t1",
|
||||
"select acos(c5) from t1",
|
||||
"select acos(c6) from t1",
|
||||
f"select acos(c1) from {dbname}.t1",
|
||||
f"select acos(c2) from {dbname}.t1",
|
||||
f"select acos(c3) from {dbname}.t1",
|
||||
f"select acos(c4) from {dbname}.t1",
|
||||
f"select acos(c5) from {dbname}.t1",
|
||||
f"select acos(c6) from {dbname}.t1",
|
||||
|
||||
"select acos(c1) from ct1",
|
||||
"select acos(c2) from ct1",
|
||||
"select acos(c3) from ct1",
|
||||
"select acos(c4) from ct1",
|
||||
"select acos(c5) from ct1",
|
||||
"select acos(c6) from ct1",
|
||||
f"select acos(c1) from {dbname}.ct1",
|
||||
f"select acos(c2) from {dbname}.ct1",
|
||||
f"select acos(c3) from {dbname}.ct1",
|
||||
f"select acos(c4) from {dbname}.ct1",
|
||||
f"select acos(c5) from {dbname}.ct1",
|
||||
f"select acos(c6) from {dbname}.ct1",
|
||||
|
||||
"select acos(c1) from ct3",
|
||||
"select acos(c2) from ct3",
|
||||
"select acos(c3) from ct3",
|
||||
"select acos(c4) from ct3",
|
||||
"select acos(c5) from ct3",
|
||||
"select acos(c6) from ct3",
|
||||
f"select acos(c1) from {dbname}.ct3",
|
||||
f"select acos(c2) from {dbname}.ct3",
|
||||
f"select acos(c3) from {dbname}.ct3",
|
||||
f"select acos(c4) from {dbname}.ct3",
|
||||
f"select acos(c5) from {dbname}.ct3",
|
||||
f"select acos(c6) from {dbname}.ct3",
|
||||
|
||||
"select acos(c1) from stb1",
|
||||
"select acos(c2) from stb1",
|
||||
"select acos(c3) from stb1",
|
||||
"select acos(c4) from stb1",
|
||||
"select acos(c5) from stb1",
|
||||
"select acos(c6) from stb1",
|
||||
f"select acos(c1) from {dbname}.stb1",
|
||||
f"select acos(c2) from {dbname}.stb1",
|
||||
f"select acos(c3) from {dbname}.stb1",
|
||||
f"select acos(c4) from {dbname}.stb1",
|
||||
f"select acos(c5) from {dbname}.stb1",
|
||||
f"select acos(c6) from {dbname}.stb1",
|
||||
|
||||
"select acos(c6) as alisb from stb1",
|
||||
"select acos(c6) alisb from stb1",
|
||||
f"select acos(c6) as alisb from {dbname}.stb1",
|
||||
f"select acos(c6) alisb from {dbname}.stb1",
|
||||
]
|
||||
|
||||
for type_sql in type_sql_lists:
|
||||
tdSql.query(type_sql)
|
||||
|
||||
def basic_acos_function(self):
|
||||
def basic_acos_function(self, dbname="db"):
|
||||
|
||||
# basic query
|
||||
tdSql.query("select c1 from ct3")
|
||||
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select c1 from t1")
|
||||
tdSql.query(f"select c1 from {dbname}.t1")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select c1 from stb1")
|
||||
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
# used for empty table , ct3 is empty
|
||||
tdSql.query("select acos(c1) from ct3")
|
||||
tdSql.query(f"select acos(c1) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select acos(c2) from ct3")
|
||||
tdSql.query(f"select acos(c2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select acos(c3) from ct3")
|
||||
tdSql.query(f"select acos(c3) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select acos(c4) from ct3")
|
||||
tdSql.query(f"select acos(c4) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select acos(c5) from ct3")
|
||||
tdSql.query(f"select acos(c5) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select acos(c6) from ct3")
|
||||
tdSql.query(f"select acos(c6) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
|
||||
# # used for regular table
|
||||
tdSql.query("select acos(c1) from t1")
|
||||
tdSql.query(f"select acos(c1) from {dbname}.t1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1 , 0, 0.000000000)
|
||||
tdSql.checkData(3 , 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(3, 3, 33)
|
||||
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(3, 4, 33)
|
||||
tdSql.checkData(5, 5, None)
|
||||
|
||||
self.check_result_auto_acos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from t1")
|
||||
self.check_result_auto_acos( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from {dbname}.t1")
|
||||
|
||||
# used for sub table
|
||||
tdSql.query("select c2 ,acos(c2) from ct1")
|
||||
tdSql.query(f"select c2 ,acos(c2) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1 , 1, None)
|
||||
tdSql.checkData(3 , 1, None)
|
||||
tdSql.checkData(4 , 1, 1.570796327)
|
||||
|
||||
tdSql.query("select c1, c5 ,acos(c5) from ct4")
|
||||
tdSql.query(f"select c1, c5 ,acos(c5) from {dbname}.ct4")
|
||||
tdSql.checkData(0 , 2, None)
|
||||
tdSql.checkData(1 , 2, None)
|
||||
tdSql.checkData(2 , 2, None)
|
||||
tdSql.checkData(3 , 2, None)
|
||||
tdSql.checkData(5 , 2, None)
|
||||
|
||||
self.check_result_auto_acos( "select c1, c2, c3 , c4, c5 from ct1", "select acos(c1), acos(c2) ,acos(c3), acos(c4), acos(c5) from ct1")
|
||||
self.check_result_auto_acos( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select acos(c1), acos(c2) ,acos(c3), acos(c4), acos(c5) from {dbname}.ct1")
|
||||
|
||||
# nest query for acos functions
|
||||
tdSql.query("select c4 , acos(c4) ,acos(acos(c4)) , acos(acos(acos(c4))) from ct1;")
|
||||
tdSql.query(f"select c4 , acos(c4) ,acos(acos(c4)) , acos(acos(acos(c4))) from {dbname}.ct1;")
|
||||
tdSql.checkData(0 , 0 , 88)
|
||||
tdSql.checkData(0 , 1 , None)
|
||||
tdSql.checkData(0 , 2 , None)
|
||||
|
@ -286,22 +286,22 @@ class TDTestCase:
|
|||
|
||||
# used for stable table
|
||||
|
||||
tdSql.query("select acos(c1) from stb1")
|
||||
tdSql.query(f"select acos(c1) from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
|
||||
# used for not exists table
|
||||
tdSql.error("select acos(c1) from stbbb1")
|
||||
tdSql.error("select acos(c1) from tbname")
|
||||
tdSql.error("select acos(c1) from ct5")
|
||||
tdSql.error(f"select acos(c1) from {dbname}.stbbb1")
|
||||
tdSql.error(f"select acos(c1) from {dbname}.tbname")
|
||||
tdSql.error(f"select acos(c1) from {dbname}.ct5")
|
||||
|
||||
# mix with common col
|
||||
tdSql.query("select c1, acos(c1) from ct1")
|
||||
tdSql.query("select c2, acos(c2) from ct4")
|
||||
tdSql.query(f"select c1, acos(c1) from {dbname}.ct1")
|
||||
tdSql.query(f"select c2, acos(c2) from {dbname}.ct4")
|
||||
|
||||
|
||||
# mix with common functions
|
||||
tdSql.query("select c1, acos(c1),acos(c1), acos(acos(c1)) from ct4 ")
|
||||
tdSql.query(f"select c1, acos(c1),acos(c1), acos(acos(c1)) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0 , 0 ,None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(0 , 2 ,None)
|
||||
|
@ -312,24 +312,24 @@ class TDTestCase:
|
|||
tdSql.checkData(3 , 2 ,None)
|
||||
tdSql.checkData(3 , 3 ,None)
|
||||
|
||||
tdSql.query("select c1, acos(c1),c5, floor(c5) from stb1 ")
|
||||
tdSql.query(f"select c1, acos(c1),c5, floor(c5) from {dbname}.stb1 ")
|
||||
|
||||
# # mix with agg functions , not support
|
||||
tdSql.error("select c1, acos(c1),c5, count(c5) from stb1 ")
|
||||
tdSql.error("select c1, acos(c1),c5, count(c5) from ct1 ")
|
||||
tdSql.error("select acos(c1), count(c5) from stb1 ")
|
||||
tdSql.error("select acos(c1), count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from stb1 ")
|
||||
tdSql.error(f"select c1, acos(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1, acos(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select acos(c1), count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select acos(c1), count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||
|
||||
# agg functions mix with agg functions
|
||||
|
||||
tdSql.query("select max(c5), count(c5) from stb1")
|
||||
tdSql.query("select max(c5), count(c5) from ct1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||
|
||||
|
||||
# # bug fix for compute
|
||||
tdSql.query("select c1, acos(c1) -0 ,acos(c1-4)-0 from ct4 ")
|
||||
tdSql.query(f"select c1, acos(c1) -0 ,acos(c1-4)-0 from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -337,7 +337,7 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(1, 2, None)
|
||||
|
||||
tdSql.query(" select c1, acos(c1) -0 ,acos(c1-0.1)-0.1 from ct4")
|
||||
tdSql.query(f" select c1, acos(c1) -0 ,acos(c1-0.1)-0.1 from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -345,35 +345,35 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(1, 2, None)
|
||||
|
||||
tdSql.query("select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ct1")
|
||||
tdSql.query(f"select c1, acos(c1), c2, acos(c2), c3, acos(c3) from {dbname}.ct1")
|
||||
|
||||
def test_big_number(self):
|
||||
def test_big_number(self, dbname="db"):
|
||||
|
||||
tdSql.query("select c1, acos(100000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, acos(100000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.checkData(4, 1, None)
|
||||
|
||||
|
||||
tdSql.query("select c1, acos(10000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, acos(10000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.checkData(4, 1, None)
|
||||
|
||||
tdSql.query("select c1, acos(10000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query("select c1, acos(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.checkData(1, 1, None)
|
||||
|
||||
tdSql.query("select c1, acos(10000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query("select c1, acos(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.checkData(4, 1, None)
|
||||
|
||||
tdSql.query("select c1, acos(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query("select c1, acos(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||
|
||||
tdSql.checkData(4, 1, None)
|
||||
|
||||
tdSql.query("select c1, acos(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, acos(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
|
||||
def abs_func_filter(self):
|
||||
tdSql.execute("use db")
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(acos(c1)-0.5) from ct4 where c1>5 ")
|
||||
def abs_func_filter(self, dbname="db"):
|
||||
tdSql.execute(f"use {dbname}")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(acos(c1)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,8.000000000)
|
||||
|
@ -381,7 +381,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,7.900000000)
|
||||
tdSql.checkData(0,4,None)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(acos(c1)-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(acos(c1)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -389,7 +389,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,None)
|
||||
|
||||
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(acos(c1)-0.5) from ct4 where c1<acos(c1) limit 1 ")
|
||||
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(acos(c1)-0.5) from {dbname}.ct4 where c1<acos(c1) limit 1 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,0)
|
||||
tdSql.checkData(0,1,0)
|
||||
|
@ -401,41 +401,41 @@ class TDTestCase:
|
|||
def pow_Arithmetic(self):
|
||||
pass
|
||||
|
||||
def check_boundary_values(self):
|
||||
def check_boundary_values(self, dbname="bound_test"):
|
||||
|
||||
PI=3.1415926
|
||||
|
||||
tdSql.execute("drop database if exists bound_test")
|
||||
tdSql.execute("create database if not exists bound_test")
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname}")
|
||||
time.sleep(3)
|
||||
tdSql.execute("use bound_test")
|
||||
tdSql.execute(f"use {dbname}")
|
||||
tdSql.execute(
|
||||
"create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
)
|
||||
tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )')
|
||||
tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )')
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.error(
|
||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
self.check_result_auto_acos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from sub1_bound")
|
||||
self.check_result_auto_acos( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.sub1_bound ", f"select acos(abs(c1)), acos(abs(c2)) ,acos(abs(c3)), acos(abs(c4)), acos(abs(c5)) from {dbname}.sub1_bound")
|
||||
|
||||
self.check_result_auto_acos( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select acos(c1), acos(c2) ,acos(c3), acos(c3), acos(c2) ,acos(c1) from sub1_bound")
|
||||
self.check_result_auto_acos( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select acos(c1), acos(c2) ,acos(c3), acos(c3), acos(c2) ,acos(c1) from {dbname}.sub1_bound")
|
||||
|
||||
self.check_result_auto_acos("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select acos(abs(c1)) from sub1_bound" )
|
||||
self.check_result_auto_acos(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select acos(abs(c1)) from {dbname}.sub1_bound" )
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query("select acos(abs(c1)) ,acos(abs(c2)) , acos(abs(c3)) , acos(abs(c4)), acos(abs(c5)), acos(abs(c6)) from sub1_bound ")
|
||||
tdSql.query(f"select acos(abs(c1)) ,acos(abs(c2)) , acos(abs(c3)) , acos(abs(c4)), acos(abs(c5)), acos(abs(c6)) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0,0,None)
|
||||
tdSql.checkData(0,1,None)
|
||||
tdSql.checkData(0,2,None)
|
||||
|
@ -453,44 +453,44 @@ class TDTestCase:
|
|||
tdSql.checkData(3,4,None)
|
||||
|
||||
# check + - * / in functions
|
||||
tdSql.query("select acos(abs(c1+1)) ,acos(abs(c2)) , acos(abs(c3*1)) , acos(abs(c4/2)), acos(abs(c5))/2, acos(abs(c6)) from sub1_bound ")
|
||||
tdSql.query(f"select acos(abs(c1+1)) ,acos(abs(c2)) , acos(abs(c3*1)) , acos(abs(c4/2)), acos(abs(c5))/2, acos(abs(c6)) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0,0,None)
|
||||
tdSql.checkData(0,1,None)
|
||||
tdSql.checkData(0,2,None)
|
||||
tdSql.checkData(0,3,None)
|
||||
|
||||
tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);")
|
||||
tdSql.execute(f'create table tb1 using st tags (1)')
|
||||
tdSql.execute(f'create table tb2 using st tags (2)')
|
||||
tdSql.execute(f'create table tb3 using st tags (3)')
|
||||
tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 ))
|
||||
tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI ))
|
||||
tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
||||
tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
||||
tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5))
|
||||
tdSql.execute(f"create stable {dbname}.st (ts timestamp, num1 float, num2 double) tags (t1 int);")
|
||||
tdSql.execute(f'create table {dbname}.tb1 using {dbname}.st tags (1)')
|
||||
tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)')
|
||||
tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)')
|
||||
tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})')
|
||||
tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})')
|
||||
tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||
tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})')
|
||||
tdSql.execute(f'insert into {dbname}.tb1 values (now(), {PI*2.5}, {PI*2.5})')
|
||||
|
||||
tdSql.execute('insert into tb2 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 ))
|
||||
tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI ))
|
||||
tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
||||
tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
||||
tdSql.execute('insert into tb2 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5))
|
||||
tdSql.execute(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})')
|
||||
tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})')
|
||||
tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||
tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {PI*2}, {PI*2})')
|
||||
tdSql.execute(f'insert into {dbname}.tb2 values (now(), {PI*2.5}, {PI*2.5})')
|
||||
|
||||
for i in range(100):
|
||||
tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2))
|
||||
tdSql.execute(f'insert into {dbname}.tb3 values (now()+{i}s, {PI*(5+i)/2}, {PI*(5+i)/2})')
|
||||
|
||||
self.check_result_auto_acos("select num1,num2 from tb3;" , "select acos(num1),acos(num2) from tb3")
|
||||
self.check_result_auto_acos(f"select num1,num2 from {dbname}.tb3;" , f"select acos(num1),acos(num2) from {dbname}.tb3")
|
||||
|
||||
def support_super_table_test(self):
|
||||
tdSql.execute(" use db ")
|
||||
self.check_result_auto_acos( " select c5 from stb1 order by ts " , "select acos(c5) from stb1 order by ts" )
|
||||
self.check_result_auto_acos( " select c5 from stb1 order by tbname " , "select acos(c5) from stb1 order by tbname" )
|
||||
self.check_result_auto_acos( " select c5 from stb1 where c1 > 0 order by tbname " , "select acos(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_acos( " select c5 from stb1 where c1 > 0 order by tbname " , "select acos(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
def support_super_table_test(self, dbname="db"):
|
||||
tdSql.execute(f" use {dbname} ")
|
||||
self.check_result_auto_acos( f" select c5 from {dbname}.stb1 order by ts " , f"select acos(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_acos( f" select c5 from {dbname}.stb1 order by tbname " , f"select acos(c5) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_acos( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select acos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_acos( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select acos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto_acos( " select t1,c5 from stb1 order by ts " , "select acos(t1), acos(c5) from stb1 order by ts" )
|
||||
self.check_result_auto_acos( " select t1,c5 from stb1 order by tbname " , "select acos(t1) ,acos(c5) from stb1 order by tbname" )
|
||||
self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) ,acos(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) , acos(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_acos( f" select t1,c5 from {dbname}.stb1 order by ts " , f"select acos(t1), acos(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_acos( f" select t1,c5 from {dbname}.stb1 order by tbname " , f"select acos(t1) ,acos(c5) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_acos( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select acos(t1) ,acos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_acos( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select acos(t1) , acos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
pass
|
||||
|
||||
|
||||
|
@ -526,9 +526,9 @@ class TDTestCase:
|
|||
|
||||
self.abs_func_filter()
|
||||
|
||||
tdLog.printNoPrefix("==========step7: acos filter query ============")
|
||||
# tdLog.printNoPrefix("==========step7: acos filter query ============")
|
||||
|
||||
self.abs_func_filter()
|
||||
# self.abs_func_filter()
|
||||
|
||||
tdLog.printNoPrefix("==========step8: check acos result of stable query ============")
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import json
|
|||
from dataclasses import dataclass, field
|
||||
from typing import List, Any, Tuple
|
||||
|
||||
from certifi import where
|
||||
from util.log import tdLog
|
||||
from util.sql import tdSql
|
||||
from util.cases import tdCases
|
||||
|
|
|
@ -380,9 +380,9 @@ class TDTestCase:
|
|||
tdSql.query("select count(*) from ct1")
|
||||
tdSql.checkData(0, 0, self.rows)
|
||||
|
||||
# tdSql.execute("flush database db")
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.execute("flush database db")
|
||||
# tdDnodes.stop(1)
|
||||
# tdDnodes.start(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
tdSql.query("select count(*) from ct1")
|
||||
|
|
|
@ -20,6 +20,8 @@ NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
|
|||
UN_NUM_COL = [BOOL_COL, BINARY_COL, NCHAR_COL, ]
|
||||
TS_TYPE_COL = [TS_COL]
|
||||
|
||||
DBNAME = "db"
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self, conn, logSql):
|
||||
|
@ -54,14 +56,14 @@ class TDTestCase:
|
|||
where_condition = self.__where_condition(condition)
|
||||
group_condition = self.__group_condition(condition, having=f"{condition} is not null " )
|
||||
|
||||
tdSql.query(f"select {condition} from {tbname} {where_condition} ")
|
||||
tdSql.query(f"select {condition} from {DBNAME}.{tbname} {where_condition} ")
|
||||
datas = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||
sum_data = sum(filter(None, datas))
|
||||
tdSql.query(f"select sum( {condition} ) from {tbname} {where_condition} ")
|
||||
tdSql.query(f"select sum( {condition} ) from {DBNAME}.{tbname} {where_condition} ")
|
||||
tdSql.checkData(0, 0, sum_data)
|
||||
|
||||
tdSql.query(f"select {condition} from {tbname} {where_condition} {group_condition} ")
|
||||
tdSql.query(f"select sum( {condition} ) from {tbname} {where_condition} {group_condition} ")
|
||||
tdSql.query(f"select {condition} from {DBNAME}.{tbname} {where_condition} {group_condition} ")
|
||||
tdSql.query(f"select sum( {condition} ) from {DBNAME}.{tbname} {where_condition} {group_condition} ")
|
||||
|
||||
def __sum_err_check(self,tbanme):
|
||||
sqls = []
|
||||
|
@ -69,19 +71,19 @@ class TDTestCase:
|
|||
for un_num_col in UN_NUM_COL:
|
||||
sqls.extend(
|
||||
(
|
||||
f"select sum( {un_num_col} ) from {tbanme} ",
|
||||
f"select sum(ceil( {un_num_col} )) from {tbanme} ",
|
||||
f"select sum( {un_num_col} ) from {DBNAME}.{tbanme} ",
|
||||
f"select sum(ceil( {un_num_col} )) {DBNAME}.from {tbanme} ",
|
||||
)
|
||||
)
|
||||
# sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL )
|
||||
|
||||
sqls.extend( f"select sum( {num_col} + {ts_col} ) from {tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL)
|
||||
sqls.extend( f"select sum( {num_col} + {ts_col} ) from {DBNAME}.{tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL)
|
||||
sqls.extend(
|
||||
(
|
||||
f"select sum() from {tbanme} ",
|
||||
f"select sum(*) from {tbanme} ",
|
||||
f"select sum(ccccccc) from {tbanme} ",
|
||||
f"select sum('test') from {tbanme} ",
|
||||
f"select sum() from {DBNAME}.{tbanme} ",
|
||||
f"select sum(*) from {DBNAME}.{tbanme} ",
|
||||
f"select sum(ccccccc) {DBNAME}.from {tbanme} ",
|
||||
f"select sum('test') from {DBNAME}.{tbanme} ",
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -110,16 +112,15 @@ class TDTestCase:
|
|||
|
||||
|
||||
def __create_tb(self):
|
||||
tdSql.prepare()
|
||||
|
||||
tdLog.printNoPrefix("==========step1:create table")
|
||||
create_stb_sql = f'''create table stb1(
|
||||
create_stb_sql = f'''create table {DBNAME}.stb1(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
) tags (t1 int)
|
||||
'''
|
||||
create_ntb_sql = f'''create table t1(
|
||||
create_ntb_sql = f'''create table {DBNAME}.t1(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
|
@ -129,29 +130,29 @@ class TDTestCase:
|
|||
tdSql.execute(create_ntb_sql)
|
||||
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {DBNAME}.ct{i+1} using {DBNAME}.stb1 tags ( {i+1} )')
|
||||
|
||||
def __insert_data(self, rows):
|
||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||
for i in range(rows):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )"
|
||||
f"insert into {DBNAME}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )"
|
||||
f"insert into {DBNAME}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )"
|
||||
f"insert into {DBNAME}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f'''insert into ct1 values
|
||||
f'''insert into {DBNAME}.ct1 values
|
||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', { now_time + 8 } )
|
||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', { now_time + 9 } )
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into ct4 values
|
||||
f'''insert into {DBNAME}.ct4 values
|
||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
@ -167,7 +168,7 @@ class TDTestCase:
|
|||
)
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into ct2 values
|
||||
f'''insert into {DBNAME}.ct2 values
|
||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
@ -183,13 +184,13 @@ class TDTestCase:
|
|||
)
|
||||
|
||||
for i in range(rows):
|
||||
insert_data = f'''insert into t1 values
|
||||
insert_data = f'''insert into {DBNAME}.t1 values
|
||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
||||
"binary_{i}", "nchar_{i}", { now_time - 1000 * i } )
|
||||
'''
|
||||
tdSql.execute(insert_data)
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {DBNAME}.t1 values
|
||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
@ -218,8 +219,11 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("==========step3:all check")
|
||||
self.all_test()
|
||||
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
# tdDnodes.stop(1)
|
||||
# tdDnodes.start(1)
|
||||
|
||||
tdSql.execute("flush database db")
|
||||
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
||||
|
|
|
@ -29,6 +29,17 @@ python3 ./test.py -f 1-insert/block_wise.py
|
|||
python3 ./test.py -f 1-insert/create_retentions.py
|
||||
python3 ./test.py -f 1-insert/table_param_ttl.py
|
||||
|
||||
python3 ./test.py -f 2-query/abs.py
|
||||
python3 ./test.py -f 2-query/abs.py -R
|
||||
python3 ./test.py -f 2-query/and_or_for_byte.py
|
||||
python3 ./test.py -f 2-query/and_or_for_byte.py -R
|
||||
python3 ./test.py -f 2-query/apercentile.py
|
||||
python3 ./test.py -f 2-query/apercentile.py -R
|
||||
python3 ./test.py -f 2-query/arccos.py
|
||||
python3 ./test.py -f 2-query/arccos.py -R
|
||||
|
||||
|
||||
|
||||
python3 ./test.py -f 2-query/between.py
|
||||
python3 ./test.py -f 2-query/distinct.py
|
||||
python3 ./test.py -f 2-query/varchar.py
|
||||
|
@ -74,8 +85,6 @@ python3 ./test.py -f 2-query/json_tag.py
|
|||
python3 ./test.py -f 2-query/top.py
|
||||
python3 ./test.py -f 2-query/bottom.py
|
||||
python3 ./test.py -f 2-query/percentile.py
|
||||
python3 ./test.py -f 2-query/apercentile.py
|
||||
python3 ./test.py -f 2-query/abs.py
|
||||
python3 ./test.py -f 2-query/ceil.py
|
||||
python3 ./test.py -f 2-query/floor.py
|
||||
python3 ./test.py -f 2-query/round.py
|
||||
|
@ -86,7 +95,6 @@ python3 ./test.py -f 2-query/sin.py
|
|||
python3 ./test.py -f 2-query/cos.py
|
||||
python3 ./test.py -f 2-query/tan.py
|
||||
python3 ./test.py -f 2-query/arcsin.py
|
||||
python3 ./test.py -f 2-query/arccos.py
|
||||
python3 ./test.py -f 2-query/arctan.py
|
||||
python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
||||
# python3 ./test.py -f 2-query/nestedQuery.py
|
||||
|
@ -117,7 +125,6 @@ python3 ./test.py -f 2-query/distribute_agg_avg.py
|
|||
python3 ./test.py -f 2-query/distribute_agg_stddev.py
|
||||
python3 ./test.py -f 2-query/twa.py
|
||||
python3 ./test.py -f 2-query/irate.py
|
||||
python3 ./test.py -f 2-query/and_or_for_byte.py
|
||||
python3 ./test.py -f 2-query/count_partition.py
|
||||
python3 ./test.py -f 2-query/function_null.py
|
||||
python3 ./test.py -f 2-query/queryQnode.py
|
||||
|
@ -137,7 +144,7 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -
|
|||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5
|
||||
# python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3
|
||||
# BUG Redict python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
|
||||
# BUG Redict python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
|
||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3
|
||||
|
||||
python3 ./test.py -f 7-tmq/basic5.py
|
||||
|
@ -184,7 +191,7 @@ python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb.py
|
|||
|
||||
#------------querPolicy 2-----------
|
||||
|
||||
python3 ./test.py -f 2-query/between.py -Q 2
|
||||
python3 ./test.py -f 2-query/between.py -Q 2
|
||||
python3 ./test.py -f 2-query/distinct.py -Q 2
|
||||
python3 ./test.py -f 2-query/varchar.py -Q 2
|
||||
python3 ./test.py -f 2-query/ltrim.py -Q 2
|
||||
|
@ -241,7 +248,7 @@ python3 ./test.py -f 2-query/arccos.py -Q 2
|
|||
python3 ./test.py -f 2-query/arctan.py -Q 2
|
||||
python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2
|
||||
|
||||
# python3 ./test.py -f 2-query/nestedQuery.py -Q 2
|
||||
# python3 ./test.py -f 2-query/nestedQuery.py -Q 2
|
||||
# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2
|
||||
|
||||
python3 ./test.py -f 2-query/avg.py -Q 2
|
||||
|
|
Loading…
Reference in New Issue