fix case
This commit is contained in:
parent
acc27d46e9
commit
028dba3c46
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from tabnanny import check
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -301,10 +302,29 @@ class TDSql:
|
||||||
args = (caller.filename, caller.lineno, self.sql, col_name_list, expect_col_name_list)
|
args = (caller.filename, caller.lineno, self.sql, col_name_list, expect_col_name_list)
|
||||||
tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args)
|
tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args)
|
||||||
|
|
||||||
|
def __check_equal(self, elm, expect_elm):
|
||||||
|
if not type(elm) in(list, tuple) and elm == expect_elm:
|
||||||
|
return True
|
||||||
|
if type(elm) in(list, tuple) and type(expect_elm) in(list, tuple):
|
||||||
|
if len(elm) != len(expect_elm):
|
||||||
|
return False
|
||||||
|
if len(elm) == 0:
|
||||||
|
return True
|
||||||
|
for i in range(len(elm)):
|
||||||
|
flag = self.__check_equal(elm[i], expect_elm[i])
|
||||||
|
if not flag:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def checkEqual(self, elm, expect_elm):
|
def checkEqual(self, elm, expect_elm):
|
||||||
if elm == expect_elm:
|
if elm == expect_elm:
|
||||||
tdLog.info("sql:%s, elm:%s == expect_elm:%s" % (self.sql, elm, expect_elm))
|
tdLog.info("sql:%s, elm:%s == expect_elm:%s" % (self.sql, elm, expect_elm))
|
||||||
else:
|
return
|
||||||
|
if self.__check_equal(elm, expect_elm):
|
||||||
|
tdLog.info("sql:%s, elm:%s == expect_elm:%s" % (self.sql, elm, expect_elm))
|
||||||
|
return
|
||||||
|
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
args = (caller.filename, caller.lineno, self.sql, elm, expect_elm)
|
args = (caller.filename, caller.lineno, self.sql, elm, expect_elm)
|
||||||
tdLog.exit("%s(%d) failed: sql:%s, elm:%s != expect_elm:%s" % args)
|
tdLog.exit("%s(%d) failed: sql:%s, elm:%s != expect_elm:%s" % args)
|
||||||
|
|
|
@ -15,7 +15,6 @@ class TDTestCase:
|
||||||
def init(self, conn, powSql):
|
def init(self, conn, powSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
self.PI =3.1415926
|
|
||||||
|
|
||||||
def prepare_datas(self, dbname="db"):
|
def prepare_datas(self, dbname="db"):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -9,49 +9,48 @@ from util.cases import *
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":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,
|
# "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}
|
# "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||||
def init(self, conn, powSql):
|
def init(self, conn, powSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
self.PI =3.1415926
|
|
||||||
|
|
||||||
def prepare_datas(self):
|
def prepare_datas(self, dbname="db"):
|
||||||
tdSql.execute(
|
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)
|
(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)
|
tags (t1 int)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''
|
f'''
|
||||||
create table t1
|
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)
|
(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):
|
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):
|
for i in range(9):
|
||||||
tdSql.execute(
|
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(
|
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(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 )")
|
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("insert into 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()+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()+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(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 ) ")
|
tdSql.execute(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 ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
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-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-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 )
|
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||||
|
@ -102,68 +101,68 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info("asin value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
tdLog.info("asin 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 = [
|
error_sql_lists = [
|
||||||
"select asin from t1",
|
f"select asin from {dbname}.t1",
|
||||||
# "select asin(-+--+c1 ) from t1",
|
# f"select asin(-+--+c1 ) from {dbname}.t1",
|
||||||
# "select +-asin(c1) from t1",
|
# f"select +-asin(c1) from {dbname}.t1",
|
||||||
# "select ++-asin(c1) from t1",
|
# f"select ++-asin(c1) from {dbname}.t1",
|
||||||
# "select ++--asin(c1) from t1",
|
# f"select ++--asin(c1) from {dbname}.t1",
|
||||||
# "select - -asin(c1)*0 from t1",
|
# f"select - -asin(c1)*0 from {dbname}.t1",
|
||||||
# "select asin(tbname+1) from t1 ",
|
# f"select asin(tbname+1) from {dbname}.t1 ",
|
||||||
"select asin(123--123)==1 from t1",
|
f"select asin(123--123)==1 from {dbname}.t1",
|
||||||
"select asin(c1) as 'd1' from t1",
|
f"select asin(c1) as 'd1' from {dbname}.t1",
|
||||||
"select asin(c1 ,c2) from t1",
|
f"select asin(c1 ,c2) from {dbname}.t1",
|
||||||
"select asin(c1 ,NULL ) from t1",
|
f"select asin(c1 ,NULL ) from {dbname}.t1",
|
||||||
"select asin(,) from t1;",
|
f"select asin(,) from {dbname}.t1;",
|
||||||
"select asin(asin(c1) ab from t1)",
|
f"select asin(asin(c1) ab from {dbname}.t1)",
|
||||||
"select asin(c1 ) as int from t1",
|
f"select asin(c1 ) as int from {dbname}.t1",
|
||||||
"select asin from stb1",
|
f"select asin from {dbname}.stb1",
|
||||||
# "select asin(-+--+c1) from stb1",
|
# f"select asin(-+--+c1) from {dbname}.stb1",
|
||||||
# "select +-asin(c1) from stb1",
|
# f"select +-asin(c1) from {dbname}.stb1",
|
||||||
# "select ++-asin(c1) from stb1",
|
# f"select ++-asin(c1) from {dbname}.stb1",
|
||||||
# "select ++--asin(c1) from stb1",
|
# f"select ++--asin(c1) from {dbname}.stb1",
|
||||||
# "select - -asin(c1)*0 from stb1",
|
# f"select - -asin(c1)*0 from {dbname}.stb1",
|
||||||
# "select asin(tbname+1) from stb1 ",
|
# f"select asin(tbname+1) from {dbname}.stb1 ",
|
||||||
"select asin(123--123)==1 from stb1",
|
f"select asin(123--123)==1 from {dbname}.stb1",
|
||||||
"select asin(c1) as 'd1' from stb1",
|
f"select asin(c1) as 'd1' from {dbname}.stb1",
|
||||||
"select asin(c1 ,c2 ) from stb1",
|
f"select asin(c1 ,c2 ) from {dbname}.stb1",
|
||||||
"select asin(c1 ,NULL) from stb1",
|
f"select asin(c1 ,NULL) from {dbname}.stb1",
|
||||||
"select asin(,) from stb1;",
|
f"select asin(,) from {dbname}.stb1;",
|
||||||
"select asin(asin(c1) ab from stb1)",
|
f"select asin(asin(c1) ab from {dbname}.stb1)",
|
||||||
"select asin(c1) as int from stb1"
|
f"select asin(c1) as int from {dbname}.stb1"
|
||||||
]
|
]
|
||||||
for error_sql in error_sql_lists:
|
for error_sql in error_sql_lists:
|
||||||
tdSql.error(error_sql)
|
tdSql.error(error_sql)
|
||||||
|
|
||||||
def support_types(self):
|
def support_types(self, dbname="db"):
|
||||||
type_error_sql_lists = [
|
type_error_sql_lists = [
|
||||||
"select asin(ts) from t1" ,
|
f"select asin(ts) from {dbname}.t1" ,
|
||||||
"select asin(c7) from t1",
|
f"select asin(c7) from {dbname}.t1",
|
||||||
"select asin(c8) from t1",
|
f"select asin(c8) from {dbname}.t1",
|
||||||
"select asin(c9) from t1",
|
f"select asin(c9) from {dbname}.t1",
|
||||||
"select asin(ts) from ct1" ,
|
f"select asin(ts) from {dbname}.ct1" ,
|
||||||
"select asin(c7) from ct1",
|
f"select asin(c7) from {dbname}.ct1",
|
||||||
"select asin(c8) from ct1",
|
f"select asin(c8) from {dbname}.ct1",
|
||||||
"select asin(c9) from ct1",
|
f"select asin(c9) from {dbname}.ct1",
|
||||||
"select asin(ts) from ct3" ,
|
f"select asin(ts) from {dbname}.ct3" ,
|
||||||
"select asin(c7) from ct3",
|
f"select asin(c7) from {dbname}.ct3",
|
||||||
"select asin(c8) from ct3",
|
f"select asin(c8) from {dbname}.ct3",
|
||||||
"select asin(c9) from ct3",
|
f"select asin(c9) from {dbname}.ct3",
|
||||||
"select asin(ts) from ct4" ,
|
f"select asin(ts) from {dbname}.ct4" ,
|
||||||
"select asin(c7) from ct4",
|
f"select asin(c7) from {dbname}.ct4",
|
||||||
"select asin(c8) from ct4",
|
f"select asin(c8) from {dbname}.ct4",
|
||||||
"select asin(c9) from ct4",
|
f"select asin(c9) from {dbname}.ct4",
|
||||||
"select asin(ts) from stb1" ,
|
f"select asin(ts) from {dbname}.stb1" ,
|
||||||
"select asin(c7) from stb1",
|
f"select asin(c7) from {dbname}.stb1",
|
||||||
"select asin(c8) from stb1",
|
f"select asin(c8) from {dbname}.stb1",
|
||||||
"select asin(c9) from stb1" ,
|
f"select asin(c9) from {dbname}.stb1" ,
|
||||||
|
|
||||||
"select asin(ts) from stbbb1" ,
|
f"select asin(ts) from {dbname}.stbbb1" ,
|
||||||
"select asin(c7) from stbbb1",
|
f"select asin(c7) from {dbname}.stbbb1",
|
||||||
|
|
||||||
"select asin(ts) from tbname",
|
f"select asin(ts) from {dbname}.tbname",
|
||||||
"select asin(c9) from tbname"
|
f"select asin(c9) from {dbname}.tbname"
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -172,103 +171,103 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
type_sql_lists = [
|
type_sql_lists = [
|
||||||
"select asin(c1) from t1",
|
f"select asin(c1) from {dbname}.t1",
|
||||||
"select asin(c2) from t1",
|
f"select asin(c2) from {dbname}.t1",
|
||||||
"select asin(c3) from t1",
|
f"select asin(c3) from {dbname}.t1",
|
||||||
"select asin(c4) from t1",
|
f"select asin(c4) from {dbname}.t1",
|
||||||
"select asin(c5) from t1",
|
f"select asin(c5) from {dbname}.t1",
|
||||||
"select asin(c6) from t1",
|
f"select asin(c6) from {dbname}.t1",
|
||||||
|
|
||||||
"select asin(c1) from ct1",
|
f"select asin(c1) from {dbname}.ct1",
|
||||||
"select asin(c2) from ct1",
|
f"select asin(c2) from {dbname}.ct1",
|
||||||
"select asin(c3) from ct1",
|
f"select asin(c3) from {dbname}.ct1",
|
||||||
"select asin(c4) from ct1",
|
f"select asin(c4) from {dbname}.ct1",
|
||||||
"select asin(c5) from ct1",
|
f"select asin(c5) from {dbname}.ct1",
|
||||||
"select asin(c6) from ct1",
|
f"select asin(c6) from {dbname}.ct1",
|
||||||
|
|
||||||
"select asin(c1) from ct3",
|
f"select asin(c1) from {dbname}.ct3",
|
||||||
"select asin(c2) from ct3",
|
f"select asin(c2) from {dbname}.ct3",
|
||||||
"select asin(c3) from ct3",
|
f"select asin(c3) from {dbname}.ct3",
|
||||||
"select asin(c4) from ct3",
|
f"select asin(c4) from {dbname}.ct3",
|
||||||
"select asin(c5) from ct3",
|
f"select asin(c5) from {dbname}.ct3",
|
||||||
"select asin(c6) from ct3",
|
f"select asin(c6) from {dbname}.ct3",
|
||||||
|
|
||||||
"select asin(c1) from stb1",
|
f"select asin(c1) from {dbname}.stb1",
|
||||||
"select asin(c2) from stb1",
|
f"select asin(c2) from {dbname}.stb1",
|
||||||
"select asin(c3) from stb1",
|
f"select asin(c3) from {dbname}.stb1",
|
||||||
"select asin(c4) from stb1",
|
f"select asin(c4) from {dbname}.stb1",
|
||||||
"select asin(c5) from stb1",
|
f"select asin(c5) from {dbname}.stb1",
|
||||||
"select asin(c6) from stb1",
|
f"select asin(c6) from {dbname}.stb1",
|
||||||
|
|
||||||
"select asin(c6) as alisb from stb1",
|
f"select asin(c6) as alisb from {dbname}.stb1",
|
||||||
"select asin(c6) alisb from stb1",
|
f"select asin(c6) alisb from {dbname}.stb1",
|
||||||
]
|
]
|
||||||
|
|
||||||
for type_sql in type_sql_lists:
|
for type_sql in type_sql_lists:
|
||||||
tdSql.query(type_sql)
|
tdSql.query(type_sql)
|
||||||
|
|
||||||
def basic_asin_function(self):
|
def basic_asin_function(self, dbname="db"):
|
||||||
|
|
||||||
# basic query
|
# basic query
|
||||||
tdSql.query("select c1 from ct3")
|
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select c1 from t1")
|
tdSql.query(f"select c1 from {dbname}.t1")
|
||||||
tdSql.checkRows(12)
|
tdSql.checkRows(12)
|
||||||
tdSql.query("select c1 from stb1")
|
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
# used for empty table , ct3 is empty
|
# used for empty table , ct3 is empty
|
||||||
tdSql.query("select asin(c1) from ct3")
|
tdSql.query(f"select asin(c1) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select asin(c2) from ct3")
|
tdSql.query(f"select asin(c2) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select asin(c3) from ct3")
|
tdSql.query(f"select asin(c3) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select asin(c4) from ct3")
|
tdSql.query(f"select asin(c4) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select asin(c5) from ct3")
|
tdSql.query(f"select asin(c5) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select asin(c6) from ct3")
|
tdSql.query(f"select asin(c6) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
|
||||||
# # used for regular table
|
# # used for regular table
|
||||||
tdSql.query("select asin(c1) from t1")
|
tdSql.query(f"select asin(c1) from {dbname}.t1")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(1 , 0, 1.570796327)
|
tdSql.checkData(1 , 0, 1.570796327)
|
||||||
tdSql.checkData(3 , 0, None)
|
tdSql.checkData(3 , 0, None)
|
||||||
tdSql.checkData(5 , 0, None)
|
tdSql.checkData(5 , 0, None)
|
||||||
|
|
||||||
tdSql.query("select c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 4, 1.11000)
|
tdSql.checkData(1, 4, 1.11000)
|
||||||
tdSql.checkData(3, 3, 33)
|
tdSql.checkData(3, 3, 33)
|
||||||
tdSql.checkData(5, 4, None)
|
tdSql.checkData(5, 4, None)
|
||||||
|
|
||||||
tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 5, 1.11000)
|
tdSql.checkData(1, 5, 1.11000)
|
||||||
tdSql.checkData(3, 4, 33)
|
tdSql.checkData(3, 4, 33)
|
||||||
tdSql.checkData(5, 5, None)
|
tdSql.checkData(5, 5, None)
|
||||||
|
|
||||||
self.check_result_auto_asin( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select asin(abs(c1)), asin(abs(c2)) ,asin(abs(c3)), asin(abs(c4)), asin(abs(c5)) from t1")
|
self.check_result_auto_asin( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select asin(abs(c1)), asin(abs(c2)) ,asin(abs(c3)), asin(abs(c4)), asin(abs(c5)) from {dbname}.t1")
|
||||||
|
|
||||||
# used for sub table
|
# used for sub table
|
||||||
tdSql.query("select c2 ,asin(c2) from ct1")
|
tdSql.query(f"select c2 ,asin(c2) from {dbname}.ct1")
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(1 , 1, None)
|
tdSql.checkData(1 , 1, None)
|
||||||
tdSql.checkData(3 , 1, None)
|
tdSql.checkData(3 , 1, None)
|
||||||
tdSql.checkData(4 , 1, 0.000000000)
|
tdSql.checkData(4 , 1, 0)
|
||||||
|
|
||||||
tdSql.query("select c1, c5 ,asin(c5) from ct4")
|
tdSql.query(f"select c1, c5 ,asin(c5) from {dbname}.ct4")
|
||||||
tdSql.checkData(0 , 2, None)
|
tdSql.checkData(0 , 2, None)
|
||||||
tdSql.checkData(1 , 2, None)
|
tdSql.checkData(1 , 2, None)
|
||||||
tdSql.checkData(2 , 2, None)
|
tdSql.checkData(2 , 2, None)
|
||||||
tdSql.checkData(3 , 2, None)
|
tdSql.checkData(3 , 2, None)
|
||||||
tdSql.checkData(5 , 2, None)
|
tdSql.checkData(5 , 2, None)
|
||||||
|
|
||||||
self.check_result_auto_asin( "select c1, c2, c3 , c4, c5 from ct1", "select asin(c1), asin(c2) ,asin(c3), asin(c4), asin(c5) from ct1")
|
self.check_result_auto_asin( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select asin(c1), asin(c2) ,asin(c3), asin(c4), asin(c5) from {dbname}.ct1")
|
||||||
|
|
||||||
# nest query for asin functions
|
# nest query for asin functions
|
||||||
tdSql.query("select c4 , asin(c4) ,asin(asin(c4)) , asin(asin(asin(c4))) from ct1;")
|
tdSql.query(f"select c4 , asin(c4) ,asin(asin(c4)) , asin(asin(asin(c4))) from {dbname}.ct1;")
|
||||||
tdSql.checkData(0 , 0 , 88)
|
tdSql.checkData(0 , 0 , 88)
|
||||||
tdSql.checkData(0 , 1 , None)
|
tdSql.checkData(0 , 1 , None)
|
||||||
tdSql.checkData(0 , 2 , None)
|
tdSql.checkData(0 , 2 , None)
|
||||||
|
@ -286,22 +285,22 @@ class TDTestCase:
|
||||||
|
|
||||||
# used for stable table
|
# used for stable table
|
||||||
|
|
||||||
tdSql.query("select asin(c1) from stb1")
|
tdSql.query(f"select asin(c1) from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
|
|
||||||
# used for not exists table
|
# used for not exists table
|
||||||
tdSql.error("select asin(c1) from stbbb1")
|
tdSql.error(f"select asin(c1) from {dbname}.stbbb1")
|
||||||
tdSql.error("select asin(c1) from tbname")
|
tdSql.error(f"select asin(c1) from {dbname}.tbname")
|
||||||
tdSql.error("select asin(c1) from ct5")
|
tdSql.error(f"select asin(c1) from {dbname}.ct5")
|
||||||
|
|
||||||
# mix with common col
|
# mix with common col
|
||||||
tdSql.query("select c1, asin(c1) from ct1")
|
tdSql.query(f"select c1, asin(c1) from {dbname}.ct1")
|
||||||
tdSql.query("select c2, asin(c2) from ct4")
|
tdSql.query(f"select c2, asin(c2) from {dbname}.ct4")
|
||||||
|
|
||||||
|
|
||||||
# mix with common functions
|
# mix with common functions
|
||||||
tdSql.query("select c1, asin(c1),asin(c1), asin(asin(c1)) from ct4 ")
|
tdSql.query(f"select c1, asin(c1),asin(c1), asin(asin(c1)) from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0 , 0 ,None)
|
tdSql.checkData(0 , 0 ,None)
|
||||||
tdSql.checkData(0 , 1 ,None)
|
tdSql.checkData(0 , 1 ,None)
|
||||||
tdSql.checkData(0 , 2 ,None)
|
tdSql.checkData(0 , 2 ,None)
|
||||||
|
@ -312,24 +311,24 @@ class TDTestCase:
|
||||||
tdSql.checkData(3 , 2 ,None)
|
tdSql.checkData(3 , 2 ,None)
|
||||||
tdSql.checkData(3 , 3 ,None)
|
tdSql.checkData(3 , 3 ,None)
|
||||||
|
|
||||||
tdSql.query("select c1, asin(c1),c5, floor(c5) from stb1 ")
|
tdSql.query(f"select c1, asin(c1),c5, floor(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# # mix with agg functions , not support
|
# # mix with agg functions , not support
|
||||||
tdSql.error("select c1, asin(c1),c5, count(c5) from stb1 ")
|
tdSql.error(f"select c1, asin(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select c1, asin(c1),c5, count(c5) from ct1 ")
|
tdSql.error(f"select c1, asin(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select asin(c1), count(c5) from stb1 ")
|
tdSql.error(f"select asin(c1), count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select asin(c1), count(c5) from ct1 ")
|
tdSql.error(f"select asin(c1), count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from ct1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from stb1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# agg functions mix with agg functions
|
# agg functions mix with agg functions
|
||||||
|
|
||||||
tdSql.query("select max(c5), count(c5) from stb1")
|
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||||
tdSql.query("select max(c5), count(c5) from ct1")
|
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||||
|
|
||||||
|
|
||||||
# # bug fix for compute
|
# # bug fix for compute
|
||||||
tdSql.query("select c1, asin(c1) -0 ,asin(c1-4)-0 from ct4 ")
|
tdSql.query(f"select c1, asin(c1) -0 ,asin(c1-4)-0 from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(0, 2, None)
|
tdSql.checkData(0, 2, None)
|
||||||
|
@ -337,7 +336,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(1, 1, None)
|
tdSql.checkData(1, 1, None)
|
||||||
tdSql.checkData(1, 2, None)
|
tdSql.checkData(1, 2, None)
|
||||||
|
|
||||||
tdSql.query(" select c1, asin(c1) -0 ,asin(c1-0.1)-0.1 from ct4")
|
tdSql.query(f" select c1, asin(c1) -0 ,asin(c1-0.1)-0.1 from {dbname}.ct4")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(0, 2, None)
|
tdSql.checkData(0, 2, None)
|
||||||
|
@ -345,35 +344,35 @@ class TDTestCase:
|
||||||
tdSql.checkData(1, 1, None)
|
tdSql.checkData(1, 1, None)
|
||||||
tdSql.checkData(1, 2, None)
|
tdSql.checkData(1, 2, None)
|
||||||
|
|
||||||
tdSql.query("select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ct1")
|
tdSql.query(f"select c1, asin(c1), c2, asin(c2), c3, asin(c3) from {dbname}.ct1")
|
||||||
|
|
||||||
def test_big_number(self):
|
def test_big_number(self, dbname="db"):
|
||||||
|
|
||||||
tdSql.query("select c1, asin(100000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, asin(100000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.checkData(4, 1, None)
|
tdSql.checkData(4, 1, None)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select c1, asin(10000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, asin(10000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.checkData(4, 1, None)
|
tdSql.checkData(4, 1, None)
|
||||||
|
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, asin(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, asin(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
tdSql.checkData(1, 1, None)
|
tdSql.checkData(1, 1, None)
|
||||||
|
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, asin(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, asin(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
tdSql.checkData(4, 1, None)
|
tdSql.checkData(4, 1, None)
|
||||||
|
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, asin(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, asin(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
|
|
||||||
tdSql.checkData(4, 1, None)
|
tdSql.checkData(4, 1, None)
|
||||||
|
|
||||||
tdSql.query("select c1, asin(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, asin(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
|
|
||||||
def abs_func_filter(self):
|
def abs_func_filter(self, dbname="db"):
|
||||||
tdSql.execute("use 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(asin(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(asin(c1)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,0,8)
|
tdSql.checkData(0,0,8)
|
||||||
tdSql.checkData(0,1,8.000000000)
|
tdSql.checkData(0,1,8.000000000)
|
||||||
|
@ -381,7 +380,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,7.900000000)
|
tdSql.checkData(0,3,7.900000000)
|
||||||
tdSql.checkData(0,4,None)
|
tdSql.checkData(0,4,None)
|
||||||
|
|
||||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(asin(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(asin(c1)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,5)
|
tdSql.checkData(0,0,5)
|
||||||
tdSql.checkData(0,1,5.000000000)
|
tdSql.checkData(0,1,5.000000000)
|
||||||
|
@ -389,7 +388,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,4.900000000)
|
tdSql.checkData(0,3,4.900000000)
|
||||||
tdSql.checkData(0,4,None)
|
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(asin(c1)-0.5) from ct4 where c1<asin(c1) limit 1 ")
|
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(asin(c1)-0.5) from {dbname}.ct4 where c1<asin(c1) limit 1 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,1)
|
tdSql.checkData(0,0,1)
|
||||||
tdSql.checkData(0,1,11111)
|
tdSql.checkData(0,1,11111)
|
||||||
|
@ -401,41 +400,41 @@ class TDTestCase:
|
||||||
def pow_Arithmetic(self):
|
def pow_Arithmetic(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def check_boundary_values(self):
|
def check_boundary_values(self, dbname="bound_test"):
|
||||||
|
|
||||||
PI=3.1415926
|
PI=3.1415926
|
||||||
|
|
||||||
tdSql.execute("drop database if exists bound_test")
|
tdSql.execute(f"drop database if exists {dbname}")
|
||||||
tdSql.execute("create database if not exists bound_test")
|
tdSql.execute(f"create database if not exists {dbname}")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
tdSql.execute("use bound_test")
|
tdSql.execute(f"use {dbname}")
|
||||||
tdSql.execute(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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_asin( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select asin(abs(c1)), asin(abs(c2)) ,asin(abs(c3)), asin(abs(c4)), asin(abs(c5)) from sub1_bound")
|
self.check_result_auto_asin( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.sub1_bound ", f"select asin(abs(c1)), asin(abs(c2)) ,asin(abs(c3)), asin(abs(c4)), asin(abs(c5)) from {dbname}.sub1_bound")
|
||||||
|
|
||||||
self.check_result_auto_asin( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select asin(c1), asin(c2) ,asin(c3), asin(c3), asin(c2) ,asin(c1) from sub1_bound")
|
self.check_result_auto_asin( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select asin(c1), asin(c2) ,asin(c3), asin(c3), asin(c2) ,asin(c1) from {dbname}.sub1_bound")
|
||||||
|
|
||||||
self.check_result_auto_asin("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select asin(abs(c1)) from sub1_bound" )
|
self.check_result_auto_asin(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select asin(abs(c1)) from {dbname}.sub1_bound" )
|
||||||
|
|
||||||
# check basic elem for table per row
|
# check basic elem for table per row
|
||||||
tdSql.query("select asin(abs(c1)) ,asin(abs(c2)) , asin(abs(c3)) , asin(abs(c4)), asin(abs(c5)), asin(abs(c6)) from sub1_bound ")
|
tdSql.query(f"select asin(abs(c1)) ,asin(abs(c2)) , asin(abs(c3)) , asin(abs(c4)), asin(abs(c5)), asin(abs(c6)) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
tdSql.checkData(0,1,None)
|
tdSql.checkData(0,1,None)
|
||||||
tdSql.checkData(0,2,None)
|
tdSql.checkData(0,2,None)
|
||||||
|
@ -453,44 +452,44 @@ class TDTestCase:
|
||||||
tdSql.checkData(3,4,None)
|
tdSql.checkData(3,4,None)
|
||||||
|
|
||||||
# check + - * / in functions
|
# check + - * / in functions
|
||||||
tdSql.query("select asin(abs(c1+1)) ,asin(abs(c2)) , asin(abs(c3*1)) , asin(abs(c4/2)), asin(abs(c5))/2, asin(abs(c6)) from sub1_bound ")
|
tdSql.query(f"select asin(abs(c1+1)) ,asin(abs(c2)) , asin(abs(c3*1)) , asin(abs(c4/2)), asin(abs(c5))/2, asin(abs(c6)) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
tdSql.checkData(0,1,None)
|
tdSql.checkData(0,1,None)
|
||||||
tdSql.checkData(0,2,None)
|
tdSql.checkData(0,2,None)
|
||||||
tdSql.checkData(0,3,None)
|
tdSql.checkData(0,3,None)
|
||||||
|
|
||||||
tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);")
|
tdSql.execute(f"create stable {dbname}.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 {dbname}.tb1 using {dbname}.st tags (1)')
|
||||||
tdSql.execute(f'create table tb2 using st tags (2)')
|
tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)')
|
||||||
tdSql.execute(f'create table tb3 using st tags (3)')
|
tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)')
|
||||||
tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 ))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})')
|
||||||
tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI ))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})')
|
||||||
tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||||
tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})')
|
||||||
tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5))
|
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(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})')
|
||||||
tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI ))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})')
|
||||||
tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||||
tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {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(), {PI*2.5}, {PI*2.5})')
|
||||||
|
|
||||||
for i in range(100):
|
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_asin("select num1,num2 from tb3;" , "select asin(num1),asin(num2) from tb3")
|
self.check_result_auto_asin(f"select num1,num2 from {dbname}.tb3;" , f"select asin(num1),asin(num2) from {dbname}.tb3")
|
||||||
|
|
||||||
def support_super_table_test(self):
|
def support_super_table_test(self, dbname="db"):
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
self.check_result_auto_asin( " select c5 from stb1 order by ts " , "select asin(c5) from stb1 order by ts" )
|
self.check_result_auto_asin( f" select c5 from {dbname}.stb1 order by ts " , f"select asin(c5) from {dbname}.stb1 order by ts" )
|
||||||
self.check_result_auto_asin( " select c5 from stb1 order by tbname " , "select asin(c5) from stb1 order by tbname" )
|
self.check_result_auto_asin( f" select c5 from {dbname}.stb1 order by tbname " , f"select asin(c5) from {dbname}.stb1 order by tbname" )
|
||||||
self.check_result_auto_asin( " select c5 from stb1 where c1 > 0 order by tbname " , "select asin(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_asin( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select asin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
self.check_result_auto_asin( " select c5 from stb1 where c1 > 0 order by tbname " , "select asin(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_asin( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select asin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
|
|
||||||
self.check_result_auto_asin( " select t1,c5 from stb1 order by ts " , "select asin(t1), asin(c5) from stb1 order by ts" )
|
self.check_result_auto_asin( f" select t1,c5 from {dbname}.stb1 order by ts " , f"select asin(t1), asin(c5) from {dbname}.stb1 order by ts" )
|
||||||
self.check_result_auto_asin( " select t1,c5 from stb1 order by tbname " , "select asin(t1) ,asin(c5) from stb1 order by tbname" )
|
self.check_result_auto_asin( f" select t1,c5 from {dbname}.stb1 order by tbname " , f"select asin(t1) ,asin(c5) from {dbname}.stb1 order by tbname" )
|
||||||
self.check_result_auto_asin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select asin(t1) ,asin(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_asin( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select asin(t1) ,asin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
self.check_result_auto_asin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select asin(t1) , asin(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_asin( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select asin(t1) , asin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,48 +9,48 @@ from util.cases import *
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":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,
|
# "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}
|
# "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||||
def init(self, conn, powSql):
|
def init(self, conn, powSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
def prepare_datas(self):
|
def prepare_datas(self, dbname="db"):
|
||||||
tdSql.execute(
|
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)
|
(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)
|
tags (t1 int)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''
|
f'''
|
||||||
create table t1
|
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)
|
(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):
|
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):
|
for i in range(9):
|
||||||
tdSql.execute(
|
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(
|
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(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 )")
|
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("insert into 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()+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()+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(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 ) ")
|
tdSql.execute(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 ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
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-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-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 )
|
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||||
|
@ -87,7 +87,7 @@ class TDTestCase:
|
||||||
|
|
||||||
for row_index , row in enumerate(pow_result):
|
for row_index , row in enumerate(pow_result):
|
||||||
for col_index , elem in enumerate(row):
|
for col_index , elem in enumerate(row):
|
||||||
if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None):
|
if auto_result[row_index][col_index] == None and elem:
|
||||||
check_status = False
|
check_status = False
|
||||||
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
|
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
|
||||||
check_status = False
|
check_status = False
|
||||||
|
@ -99,68 +99,68 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info("atan value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
tdLog.info("atan 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 = [
|
error_sql_lists = [
|
||||||
"select atan from t1",
|
f"select atan from {dbname}.t1",
|
||||||
# "select atan(-+--+c1 ) from t1",
|
# f"select atan(-+--+c1 ) from {dbname}.t1",
|
||||||
# "select +-atan(c1) from t1",
|
# f"select +-atan(c1) from {dbname}.t1",
|
||||||
# "select ++-atan(c1) from t1",
|
# f"select ++-atan(c1) from {dbname}.t1",
|
||||||
# "select ++--atan(c1) from t1",
|
# f"select ++--atan(c1) from {dbname}.t1",
|
||||||
# "select - -atan(c1)*0 from t1",
|
# f"select - -atan(c1)*0 from {dbname}.t1",
|
||||||
# "select atan(tbname+1) from t1 ",
|
# f"select atan(tbname+1) from {dbname}.t1 ",
|
||||||
"select atan(123--123)==1 from t1",
|
f"select atan(123--123)==1 from {dbname}.t1",
|
||||||
"select atan(c1) as 'd1' from t1",
|
f"select atan(c1) as 'd1' from {dbname}.t1",
|
||||||
"select atan(c1 ,c2) from t1",
|
f"select atan(c1 ,c2) from {dbname}.t1",
|
||||||
"select atan(c1 ,NULL ) from t1",
|
f"select atan(c1 ,NULL ) from {dbname}.t1",
|
||||||
"select atan(,) from t1;",
|
f"select atan(,) from {dbname}.t1;",
|
||||||
"select atan(atan(c1) ab from t1)",
|
f"select atan(atan(c1) ab from {dbname}.t1)",
|
||||||
"select atan(c1 ) as int from t1",
|
f"select atan(c1 ) as int from {dbname}.t1",
|
||||||
"select atan from stb1",
|
f"select atan from {dbname}.stb1",
|
||||||
# "select atan(-+--+c1) from stb1",
|
# f"select atan(-+--+c1) from {dbname}.stb1",
|
||||||
# "select +-atan(c1) from stb1",
|
# f"select +-atan(c1) from {dbname}.stb1",
|
||||||
# "select ++-atan(c1) from stb1",
|
# f"select ++-atan(c1) from {dbname}.stb1",
|
||||||
# "select ++--atan(c1) from stb1",
|
# f"select ++--atan(c1) from {dbname}.stb1",
|
||||||
# "select - -atan(c1)*0 from stb1",
|
# f"select - -atan(c1)*0 from {dbname}.stb1",
|
||||||
# "select atan(tbname+1) from stb1 ",
|
# f"select atan(tbname+1) from {dbname}.stb1 ",
|
||||||
"select atan(123--123)==1 from stb1",
|
f"select atan(123--123)==1 from {dbname}.stb1",
|
||||||
"select atan(c1) as 'd1' from stb1",
|
f"select atan(c1) as 'd1' from {dbname}.stb1",
|
||||||
"select atan(c1 ,c2 ) from stb1",
|
f"select atan(c1 ,c2 ) from {dbname}.stb1",
|
||||||
"select atan(c1 ,NULL) from stb1",
|
f"select atan(c1 ,NULL) from {dbname}.stb1",
|
||||||
"select atan(,) from stb1;",
|
f"select atan(,) from {dbname}.stb1;",
|
||||||
"select atan(atan(c1) ab from stb1)",
|
f"select atan(atan(c1) ab from {dbname}.stb1)",
|
||||||
"select atan(c1) as int from stb1"
|
f"select atan(c1) as int from {dbname}.stb1"
|
||||||
]
|
]
|
||||||
for error_sql in error_sql_lists:
|
for error_sql in error_sql_lists:
|
||||||
tdSql.error(error_sql)
|
tdSql.error(error_sql)
|
||||||
|
|
||||||
def support_types(self):
|
def support_types(self, dbname="db"):
|
||||||
type_error_sql_lists = [
|
type_error_sql_lists = [
|
||||||
"select atan(ts) from t1" ,
|
f"select atan(ts) from {dbname}.t1" ,
|
||||||
"select atan(c7) from t1",
|
f"select atan(c7) from {dbname}.t1",
|
||||||
"select atan(c8) from t1",
|
f"select atan(c8) from {dbname}.t1",
|
||||||
"select atan(c9) from t1",
|
f"select atan(c9) from {dbname}.t1",
|
||||||
"select atan(ts) from ct1" ,
|
f"select atan(ts) from {dbname}.ct1" ,
|
||||||
"select atan(c7) from ct1",
|
f"select atan(c7) from {dbname}.ct1",
|
||||||
"select atan(c8) from ct1",
|
f"select atan(c8) from {dbname}.ct1",
|
||||||
"select atan(c9) from ct1",
|
f"select atan(c9) from {dbname}.ct1",
|
||||||
"select atan(ts) from ct3" ,
|
f"select atan(ts) from {dbname}.ct3" ,
|
||||||
"select atan(c7) from ct3",
|
f"select atan(c7) from {dbname}.ct3",
|
||||||
"select atan(c8) from ct3",
|
f"select atan(c8) from {dbname}.ct3",
|
||||||
"select atan(c9) from ct3",
|
f"select atan(c9) from {dbname}.ct3",
|
||||||
"select atan(ts) from ct4" ,
|
f"select atan(ts) from {dbname}.ct4" ,
|
||||||
"select atan(c7) from ct4",
|
f"select atan(c7) from {dbname}.ct4",
|
||||||
"select atan(c8) from ct4",
|
f"select atan(c8) from {dbname}.ct4",
|
||||||
"select atan(c9) from ct4",
|
f"select atan(c9) from {dbname}.ct4",
|
||||||
"select atan(ts) from stb1" ,
|
f"select atan(ts) from {dbname}.stb1" ,
|
||||||
"select atan(c7) from stb1",
|
f"select atan(c7) from {dbname}.stb1",
|
||||||
"select atan(c8) from stb1",
|
f"select atan(c8) from {dbname}.stb1",
|
||||||
"select atan(c9) from stb1" ,
|
f"select atan(c9) from {dbname}.stb1" ,
|
||||||
|
|
||||||
"select atan(ts) from stbbb1" ,
|
f"select atan(ts) from {dbname}.stbbb1" ,
|
||||||
"select atan(c7) from stbbb1",
|
f"select atan(c7) from {dbname}.stbbb1",
|
||||||
|
|
||||||
"select atan(ts) from tbname",
|
f"select atan(ts) from {dbname}.tbname",
|
||||||
"select atan(c9) from tbname"
|
f"select atan(c9) from {dbname}.tbname"
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -169,103 +169,103 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
type_sql_lists = [
|
type_sql_lists = [
|
||||||
"select atan(c1) from t1",
|
f"select atan(c1) from {dbname}.t1",
|
||||||
"select atan(c2) from t1",
|
f"select atan(c2) from {dbname}.t1",
|
||||||
"select atan(c3) from t1",
|
f"select atan(c3) from {dbname}.t1",
|
||||||
"select atan(c4) from t1",
|
f"select atan(c4) from {dbname}.t1",
|
||||||
"select atan(c5) from t1",
|
f"select atan(c5) from {dbname}.t1",
|
||||||
"select atan(c6) from t1",
|
f"select atan(c6) from {dbname}.t1",
|
||||||
|
|
||||||
"select atan(c1) from ct1",
|
f"select atan(c1) from {dbname}.ct1",
|
||||||
"select atan(c2) from ct1",
|
f"select atan(c2) from {dbname}.ct1",
|
||||||
"select atan(c3) from ct1",
|
f"select atan(c3) from {dbname}.ct1",
|
||||||
"select atan(c4) from ct1",
|
f"select atan(c4) from {dbname}.ct1",
|
||||||
"select atan(c5) from ct1",
|
f"select atan(c5) from {dbname}.ct1",
|
||||||
"select atan(c6) from ct1",
|
f"select atan(c6) from {dbname}.ct1",
|
||||||
|
|
||||||
"select atan(c1) from ct3",
|
f"select atan(c1) from {dbname}.ct3",
|
||||||
"select atan(c2) from ct3",
|
f"select atan(c2) from {dbname}.ct3",
|
||||||
"select atan(c3) from ct3",
|
f"select atan(c3) from {dbname}.ct3",
|
||||||
"select atan(c4) from ct3",
|
f"select atan(c4) from {dbname}.ct3",
|
||||||
"select atan(c5) from ct3",
|
f"select atan(c5) from {dbname}.ct3",
|
||||||
"select atan(c6) from ct3",
|
f"select atan(c6) from {dbname}.ct3",
|
||||||
|
|
||||||
"select atan(c1) from stb1",
|
f"select atan(c1) from {dbname}.stb1",
|
||||||
"select atan(c2) from stb1",
|
f"select atan(c2) from {dbname}.stb1",
|
||||||
"select atan(c3) from stb1",
|
f"select atan(c3) from {dbname}.stb1",
|
||||||
"select atan(c4) from stb1",
|
f"select atan(c4) from {dbname}.stb1",
|
||||||
"select atan(c5) from stb1",
|
f"select atan(c5) from {dbname}.stb1",
|
||||||
"select atan(c6) from stb1",
|
f"select atan(c6) from {dbname}.stb1",
|
||||||
|
|
||||||
"select atan(c6) as alisb from stb1",
|
f"select atan(c6) as alisb from {dbname}.stb1",
|
||||||
"select atan(c6) alisb from stb1",
|
f"select atan(c6) alisb from {dbname}.stb1",
|
||||||
]
|
]
|
||||||
|
|
||||||
for type_sql in type_sql_lists:
|
for type_sql in type_sql_lists:
|
||||||
tdSql.query(type_sql)
|
tdSql.query(type_sql)
|
||||||
|
|
||||||
def basic_atan_function(self):
|
def basic_atan_function(self, dbname="db"):
|
||||||
|
|
||||||
# basic query
|
# basic query
|
||||||
tdSql.query("select c1 from ct3")
|
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select c1 from t1")
|
tdSql.query(f"select c1 from {dbname}.t1")
|
||||||
tdSql.checkRows(12)
|
tdSql.checkRows(12)
|
||||||
tdSql.query("select c1 from stb1")
|
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
# used for empty table , ct3 is empty
|
# used for empty table , ct3 is empty
|
||||||
tdSql.query("select atan(c1) from ct3")
|
tdSql.query(f"select atan(c1) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select atan(c2) from ct3")
|
tdSql.query(f"select atan(c2) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select atan(c3) from ct3")
|
tdSql.query(f"select atan(c3) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select atan(c4) from ct3")
|
tdSql.query(f"select atan(c4) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select atan(c5) from ct3")
|
tdSql.query(f"select atan(c5) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select atan(c6) from ct3")
|
tdSql.query(f"select atan(c6) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
|
||||||
# # used for regular table
|
# # used for regular table
|
||||||
tdSql.query("select atan(c1) from t1")
|
tdSql.query(f"select atan(c1) from {dbname}.t1")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(1 , 0, 0.785398163)
|
tdSql.checkData(1 , 0, 0.785398163)
|
||||||
tdSql.checkData(3 , 0, 1.249045772)
|
tdSql.checkData(3 , 0, 1.249045772)
|
||||||
tdSql.checkData(5 , 0, None)
|
tdSql.checkData(5 , 0, None)
|
||||||
|
|
||||||
tdSql.query("select c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 4, 1.11000)
|
tdSql.checkData(1, 4, 1.11000)
|
||||||
tdSql.checkData(3, 3, 33)
|
tdSql.checkData(3, 3, 33)
|
||||||
tdSql.checkData(5, 4, None)
|
tdSql.checkData(5, 4, None)
|
||||||
|
|
||||||
tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 5, 1.11000)
|
tdSql.checkData(1, 5, 1.11000)
|
||||||
tdSql.checkData(3, 4, 33)
|
tdSql.checkData(3, 4, 33)
|
||||||
tdSql.checkData(5, 5, None)
|
tdSql.checkData(5, 5, None)
|
||||||
|
|
||||||
self.check_result_auto_atan( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select atan(abs(c1)), atan(abs(c2)) ,atan(abs(c3)), atan(abs(c4)), atan(abs(c5)) from t1")
|
self.check_result_auto_atan( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select atan(abs(c1)), atan(abs(c2)) ,atan(abs(c3)), atan(abs(c4)), atan(abs(c5)) from {dbname}.t1")
|
||||||
|
|
||||||
# used for sub table
|
# used for sub table
|
||||||
tdSql.query("select c2 ,atan(c2) from ct1")
|
tdSql.query(f"select c2 ,atan(c2) from {dbname}.ct1")
|
||||||
tdSql.checkData(0, 1, 1.570785077)
|
tdSql.checkData(0, 1, 1.570785077)
|
||||||
tdSql.checkData(1 , 1, 1.570783470)
|
tdSql.checkData(1 , 1, 1.570783470)
|
||||||
tdSql.checkData(3 , 1, 1.570778327)
|
tdSql.checkData(3 , 1, 1.570778327)
|
||||||
tdSql.checkData(4 , 1, 0.000000000)
|
tdSql.checkData(4 , 1, 0)
|
||||||
|
|
||||||
tdSql.query("select c1, c5 ,atan(c5) from ct4")
|
tdSql.query(f"select c1, c5 ,atan(c5) from {dbname}.ct4")
|
||||||
tdSql.checkData(0 , 2, None)
|
tdSql.checkData(0 , 2, None)
|
||||||
tdSql.checkData(1 , 2, 1.458656162)
|
tdSql.checkData(1 , 2, 1.458656162)
|
||||||
tdSql.checkData(2 , 2, 1.442799803)
|
tdSql.checkData(2 , 2, 1.442799803)
|
||||||
tdSql.checkData(3 , 2, 1.421759533)
|
tdSql.checkData(3 , 2, 1.421759533)
|
||||||
tdSql.checkData(5 , 2, None)
|
tdSql.checkData(5 , 2, None)
|
||||||
|
|
||||||
self.check_result_auto_atan( "select c1, c2, c3 , c4, c5 from ct1", "select atan(c1), atan(c2) ,atan(c3), atan(c4), atan(c5) from ct1")
|
self.check_result_auto_atan( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select atan(c1), atan(c2) ,atan(c3), atan(c4), atan(c5) from {dbname}.ct1")
|
||||||
|
|
||||||
# nest query for atan functions
|
# nest query for atan functions
|
||||||
tdSql.query("select c4 , atan(c4) ,atan(atan(c4)) , atan(atan(atan(c4))) from ct1;")
|
tdSql.query(f"select c4 , atan(c4) ,atan(atan(c4)) , atan(atan(atan(c4))) from {dbname}.ct1;")
|
||||||
tdSql.checkData(0 , 0 , 88)
|
tdSql.checkData(0 , 0 , 88)
|
||||||
tdSql.checkData(0 , 1 , 1.559433180)
|
tdSql.checkData(0 , 1 , 1.559433180)
|
||||||
tdSql.checkData(0 , 2 , 1.000590740)
|
tdSql.checkData(0 , 2 , 1.000590740)
|
||||||
|
@ -283,22 +283,22 @@ class TDTestCase:
|
||||||
|
|
||||||
# used for stable table
|
# used for stable table
|
||||||
|
|
||||||
tdSql.query("select atan(c1) from stb1")
|
tdSql.query(f"select atan(c1) from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
|
|
||||||
# used for not exists table
|
# used for not exists table
|
||||||
tdSql.error("select atan(c1) from stbbb1")
|
tdSql.error(f"select atan(c1) from {dbname}.stbbb1")
|
||||||
tdSql.error("select atan(c1) from tbname")
|
tdSql.error(f"select atan(c1) from {dbname}.tbname")
|
||||||
tdSql.error("select atan(c1) from ct5")
|
tdSql.error(f"select atan(c1) from {dbname}.ct5")
|
||||||
|
|
||||||
# mix with common col
|
# mix with common col
|
||||||
tdSql.query("select c1, atan(c1) from ct1")
|
tdSql.query(f"select c1, atan(c1) from {dbname}.ct1")
|
||||||
tdSql.query("select c2, atan(c2) from ct4")
|
tdSql.query(f"select c2, atan(c2) from {dbname}.ct4")
|
||||||
|
|
||||||
|
|
||||||
# mix with common functions
|
# mix with common functions
|
||||||
tdSql.query("select c1, atan(c1),atan(c1), atan(atan(c1)) from ct4 ")
|
tdSql.query(f"select c1, atan(c1),atan(c1), atan(atan(c1)) from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0 , 0 ,None)
|
tdSql.checkData(0 , 0 ,None)
|
||||||
tdSql.checkData(0 , 1 ,None)
|
tdSql.checkData(0 , 1 ,None)
|
||||||
tdSql.checkData(0 , 2 ,None)
|
tdSql.checkData(0 , 2 ,None)
|
||||||
|
@ -309,24 +309,24 @@ class TDTestCase:
|
||||||
tdSql.checkData(3 , 2 ,1.405647649)
|
tdSql.checkData(3 , 2 ,1.405647649)
|
||||||
tdSql.checkData(3 , 3 ,0.952449745)
|
tdSql.checkData(3 , 3 ,0.952449745)
|
||||||
|
|
||||||
tdSql.query("select c1, atan(c1),c5, floor(c5) from stb1 ")
|
tdSql.query(f"select c1, atan(c1),c5, floor(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# # mix with agg functions , not support
|
# # mix with agg functions , not support
|
||||||
tdSql.error("select c1, atan(c1),c5, count(c5) from stb1 ")
|
tdSql.error(f"select c1, atan(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select c1, atan(c1),c5, count(c5) from ct1 ")
|
tdSql.error(f"select c1, atan(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select atan(c1), count(c5) from stb1 ")
|
tdSql.error(f"select atan(c1), count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select atan(c1), count(c5) from ct1 ")
|
tdSql.error(f"select atan(c1), count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from ct1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from stb1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# agg functions mix with agg functions
|
# agg functions mix with agg functions
|
||||||
|
|
||||||
tdSql.query("select max(c5), count(c5) from stb1")
|
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||||
tdSql.query("select max(c5), count(c5) from ct1")
|
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||||
|
|
||||||
|
|
||||||
# # bug fix for compute
|
# # bug fix for compute
|
||||||
tdSql.query("select c1, atan(c1) -0 ,atan(c1-4)-0 from ct4 ")
|
tdSql.query(f"select c1, atan(c1) -0 ,atan(c1-4)-0 from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(0, 2, None)
|
tdSql.checkData(0, 2, None)
|
||||||
|
@ -334,7 +334,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(1, 1, 1.446441332)
|
tdSql.checkData(1, 1, 1.446441332)
|
||||||
tdSql.checkData(1, 2, 1.325817664)
|
tdSql.checkData(1, 2, 1.325817664)
|
||||||
|
|
||||||
tdSql.query(" select c1, atan(c1) -0 ,atan(c1-0.1)-0.1 from ct4")
|
tdSql.query(f" select c1, atan(c1) -0 ,atan(c1-0.1)-0.1 from {dbname}.ct4")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(0, 2, None)
|
tdSql.checkData(0, 2, None)
|
||||||
|
@ -342,35 +342,35 @@ class TDTestCase:
|
||||||
tdSql.checkData(1, 1, 1.446441332)
|
tdSql.checkData(1, 1, 1.446441332)
|
||||||
tdSql.checkData(1, 2, 1.344883701)
|
tdSql.checkData(1, 2, 1.344883701)
|
||||||
|
|
||||||
tdSql.query("select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ct1")
|
tdSql.query(f"select c1, atan(c1), c2, atan(c2), c3, atan(c3) from {dbname}.ct1")
|
||||||
|
|
||||||
def test_big_number(self):
|
def test_big_number(self, dbname="db"):
|
||||||
|
|
||||||
tdSql.query("select c1, atan(100000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, atan(100000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.checkData(4, 1, math.atan(100000000))
|
tdSql.checkData(4, 1, math.atan(100000000))
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select c1, atan(10000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, atan(10000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.checkData(4, 1, math.atan(10000000000000))
|
tdSql.checkData(4, 1, math.atan(10000000000000))
|
||||||
|
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, atan(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, atan(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
tdSql.checkData(1, 1, math.atan(10000000000000000000000000.0))
|
tdSql.checkData(1, 1, math.atan(10000000000000000000000000.0))
|
||||||
|
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, atan(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, atan(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
tdSql.checkData(4, 1, math.atan(10000000000000000000000000000000000.0))
|
tdSql.checkData(4, 1, math.atan(10000000000000000000000000000000000.0))
|
||||||
|
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, atan(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, atan(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
|
|
||||||
tdSql.checkData(4, 1, math.atan(10000000000000000000000000000000000000000.0))
|
tdSql.checkData(4, 1, math.atan(10000000000000000000000000000000000000000.0))
|
||||||
|
|
||||||
tdSql.query("select c1, atan(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, atan(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
|
|
||||||
def abs_func_filter(self):
|
def abs_func_filter(self, dbname="db"):
|
||||||
tdSql.execute("use 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(atan(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(atan(c1)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,0,8)
|
tdSql.checkData(0,0,8)
|
||||||
tdSql.checkData(0,1,8.000000000)
|
tdSql.checkData(0,1,8.000000000)
|
||||||
|
@ -378,7 +378,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,7.900000000)
|
tdSql.checkData(0,3,7.900000000)
|
||||||
tdSql.checkData(0,4,1.000000000)
|
tdSql.checkData(0,4,1.000000000)
|
||||||
|
|
||||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(atan(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(atan(c1)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,5)
|
tdSql.checkData(0,0,5)
|
||||||
tdSql.checkData(0,1,5.000000000)
|
tdSql.checkData(0,1,5.000000000)
|
||||||
|
@ -386,7 +386,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,4.900000000)
|
tdSql.checkData(0,3,4.900000000)
|
||||||
tdSql.checkData(0,4,1.000000000)
|
tdSql.checkData(0,4,1.000000000)
|
||||||
|
|
||||||
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(atan(c1)-0.5) from ct4 where c1=atan(c1) limit 1 ")
|
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(atan(c1)-0.5) from {dbname}.ct4 where c1=atan(c1) limit 1 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
tdSql.checkData(0,1,0)
|
tdSql.checkData(0,1,0)
|
||||||
|
@ -398,41 +398,41 @@ class TDTestCase:
|
||||||
def pow_Arithmetic(self):
|
def pow_Arithmetic(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def check_boundary_values(self):
|
def check_boundary_values(self, dbname="bound_test"):
|
||||||
|
|
||||||
PI=3.1415926
|
PI=3.1415926
|
||||||
|
|
||||||
tdSql.execute("drop database if exists bound_test")
|
tdSql.execute(f"drop database if exists {dbname}")
|
||||||
tdSql.execute("create database if not exists bound_test")
|
tdSql.execute(f"create database if not exists {dbname}")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
tdSql.execute("use bound_test")
|
tdSql.execute(f"use {dbname}")
|
||||||
tdSql.execute(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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_atan( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select atan(abs(c1)), atan(abs(c2)) ,atan(abs(c3)), atan(abs(c4)), atan(abs(c5)) from sub1_bound")
|
self.check_result_auto_atan( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.sub1_bound ", f"select atan(abs(c1)), atan(abs(c2)) ,atan(abs(c3)), atan(abs(c4)), atan(abs(c5)) from {dbname}.sub1_bound")
|
||||||
|
|
||||||
self.check_result_auto_atan( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select atan(c1), atan(c2) ,atan(c3), atan(c3), atan(c2) ,atan(c1) from sub1_bound")
|
self.check_result_auto_atan( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select atan(c1), atan(c2) ,atan(c3), atan(c3), atan(c2) ,atan(c1) from {dbname}.sub1_bound")
|
||||||
|
|
||||||
self.check_result_auto_atan("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select atan(abs(c1)) from sub1_bound" )
|
self.check_result_auto_atan(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select atan(abs(c1)) from {dbname}.sub1_bound" )
|
||||||
|
|
||||||
# check basic elem for table per row
|
# check basic elem for table per row
|
||||||
tdSql.query("select atan(abs(c1)) ,atan(abs(c2)) , atan(abs(c3)) , atan(abs(c4)), atan(abs(c5)), atan(abs(c6)) from sub1_bound ")
|
tdSql.query(f"select atan(abs(c1)) ,atan(abs(c2)) , atan(abs(c3)) , atan(abs(c4)), atan(abs(c5)), atan(abs(c6)) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,math.atan(2147483647))
|
tdSql.checkData(0,0,math.atan(2147483647))
|
||||||
tdSql.checkData(0,1,math.atan(9223372036854775807))
|
tdSql.checkData(0,1,math.atan(9223372036854775807))
|
||||||
tdSql.checkData(0,2,math.atan(32767))
|
tdSql.checkData(0,2,math.atan(32767))
|
||||||
|
@ -450,47 +450,47 @@ class TDTestCase:
|
||||||
tdSql.checkData(3,4,math.atan(339999995214436424907732413799364296704.00000))
|
tdSql.checkData(3,4,math.atan(339999995214436424907732413799364296704.00000))
|
||||||
|
|
||||||
# check + - * / in functions
|
# check + - * / in functions
|
||||||
tdSql.query("select atan(abs(c1+1)) ,atan(abs(c2)) , atan(abs(c3*1)) , atan(abs(c4/2)), atan(abs(c5))/2, atan(abs(c6)) from sub1_bound ")
|
tdSql.query(f"select atan(abs(c1+1)) ,atan(abs(c2)) , atan(abs(c3*1)) , atan(abs(c4/2)), atan(abs(c5))/2, atan(abs(c6)) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,math.atan(2147483648.000000000))
|
tdSql.checkData(0,0,math.atan(2147483648.000000000))
|
||||||
tdSql.checkData(0,1,math.atan(9223372036854775807))
|
tdSql.checkData(0,1,math.atan(9223372036854775807))
|
||||||
tdSql.checkData(0,2,math.atan(32767.000000000))
|
tdSql.checkData(0,2,math.atan(32767.000000000))
|
||||||
tdSql.checkData(0,3,math.atan(63.500000000))
|
tdSql.checkData(0,3,math.atan(63.500000000))
|
||||||
|
|
||||||
tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);")
|
tdSql.execute(f"create stable {dbname}.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 {dbname}.tb1 using {dbname}.st tags (1)')
|
||||||
tdSql.execute(f'create table tb2 using st tags (2)')
|
tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)')
|
||||||
tdSql.execute(f'create table tb3 using st tags (3)')
|
tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)')
|
||||||
tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 ))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})')
|
||||||
tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI ))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})')
|
||||||
tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||||
tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})')
|
||||||
tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5))
|
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(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})')
|
||||||
tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI ))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})')
|
||||||
tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||||
tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {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(), {PI*2.5}, {PI*2.5})')
|
||||||
|
|
||||||
for i in range(100):
|
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_atan("select num1,num2 from tb3;" , "select atan(num1),atan(num2) from tb3")
|
self.check_result_auto_atan(f"select num1,num2 from {dbname}.tb3;" , f"select atan(num1),atan(num2) from {dbname}.tb3")
|
||||||
|
|
||||||
|
def support_super_table_test(self, dbname="db"):
|
||||||
|
tdSql.execute(f" use {dbname} ")
|
||||||
|
self.check_result_auto_atan( f" select c5 from {dbname}.stb1 order by ts " , f"select atan(c5) from {dbname}.stb1 order by ts" )
|
||||||
|
self.check_result_auto_atan( f" select c5 from {dbname}.stb1 order by tbname " , f"select atan(c5) from {dbname}.stb1 order by tbname" )
|
||||||
|
self.check_result_auto_atan( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select atan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
|
self.check_result_auto_atan( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select atan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
|
|
||||||
def support_super_table_test(self):
|
self.check_result_auto_atan( f" select t1,c5 from {dbname}.stb1 order by ts " , f"select atan(t1), atan(c5) from {dbname}.stb1 order by ts" )
|
||||||
tdSql.execute(" use db ")
|
self.check_result_auto_atan( f" select t1,c5 from {dbname}.stb1 order by tbname " , f"select atan(t1) ,atan(c5) from {dbname}.stb1 order by tbname" )
|
||||||
self.check_result_auto_atan( " select c5 from stb1 order by ts " , "select atan(c5) from stb1 order by ts" )
|
self.check_result_auto_atan( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select atan(t1) ,atan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
self.check_result_auto_atan( " select c5 from stb1 order by tbname " , "select atan(c5) from stb1 order by tbname" )
|
self.check_result_auto_atan( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select atan(t1) , atan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
self.check_result_auto_atan( " select c5 from stb1 where c1 > 0 order by tbname " , "select atan(c5) from stb1 where c1 > 0 order by tbname" )
|
|
||||||
self.check_result_auto_atan( " select c5 from stb1 where c1 > 0 order by tbname " , "select atan(c5) from stb1 where c1 > 0 order by tbname" )
|
|
||||||
|
|
||||||
self.check_result_auto_atan( " select t1,c5 from stb1 order by ts " , "select atan(t1), atan(c5) from stb1 order by ts" )
|
|
||||||
self.check_result_auto_atan( " select t1,c5 from stb1 order by tbname " , "select atan(t1) ,atan(c5) from stb1 order by tbname" )
|
|
||||||
self.check_result_auto_atan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select atan(t1) ,atan(c5) from stb1 where c1 > 0 order by tbname" )
|
|
||||||
self.check_result_auto_atan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select atan(t1) , atan(c5) from stb1 where c1 > 0 order by tbname" )
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
|
@ -523,12 +523,11 @@ class TDTestCase:
|
||||||
|
|
||||||
self.abs_func_filter()
|
self.abs_func_filter()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step8: check arctan result of stable query ============")
|
tdLog.printNoPrefix("==========step8: check atan result of stable query ============")
|
||||||
|
|
||||||
self.support_super_table_test()
|
self.support_super_table_test()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from pyrsistent import v
|
||||||
import taos
|
import taos
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -8,48 +9,48 @@ from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":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,
|
# "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}
|
# "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor(), True)
|
tdSql.init(conn.cursor(), False)
|
||||||
|
|
||||||
def prepare_datas(self):
|
def prepare_datas(self, dbname="db"):
|
||||||
tdSql.execute(
|
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)
|
(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)
|
tags (t1 int)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''
|
f'''
|
||||||
create table t1
|
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)
|
(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):
|
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):
|
for i in range(9):
|
||||||
tdSql.execute(
|
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(
|
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(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 )")
|
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("insert into 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()+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()+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(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 ) ")
|
tdSql.execute(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 ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
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-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-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 )
|
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||||
|
@ -80,68 +81,68 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info("avg value check pass , it work as expected ,sql is \"%s\" "%check_query )
|
tdLog.info("avg value check pass , it work as expected ,sql is \"%s\" "%check_query )
|
||||||
|
|
||||||
def test_errors(self):
|
def test_errors(self, dbname="db"):
|
||||||
error_sql_lists = [
|
error_sql_lists = [
|
||||||
"select avg from t1",
|
f"select avg from {dbname}.t1",
|
||||||
# "select avg(-+--+c1) from t1",
|
# f"select avg(-+--+c1) from {dbname}.t1",
|
||||||
# "select +-avg(c1) from t1",
|
# f"select +-avg(c1) from {dbname}.t1",
|
||||||
# "select ++-avg(c1) from t1",
|
# f"select ++-avg(c1) from {dbname}.t1",
|
||||||
# "select ++--avg(c1) from t1",
|
# f"select ++--avg(c1) from {dbname}.t1",
|
||||||
# "select - -avg(c1)*0 from t1",
|
# f"select - -avg(c1)*0 from {dbname}.t1",
|
||||||
# "select avg(tbname+1) from t1 ",
|
# f"select avg(tbname+1) from {dbname}.t1 ",
|
||||||
"select avg(123--123)==1 from t1",
|
f"select avg(123--123)==1 from {dbname}.t1",
|
||||||
"select avg(c1) as 'd1' from t1",
|
f"select avg(c1) as 'd1' from {dbname}.t1",
|
||||||
"select avg(c1 ,c2 ) from t1",
|
f"select avg(c1 ,c2 ) from {dbname}.t1",
|
||||||
"select avg(c1 ,NULL) from t1",
|
f"select avg(c1 ,NULL) from {dbname}.t1",
|
||||||
"select avg(,) from t1;",
|
f"select avg(,) from {dbname}.t1;",
|
||||||
"select avg(avg(c1) ab from t1)",
|
f"select avg(avg(c1) ab from {dbname}.t1)",
|
||||||
"select avg(c1) as int from t1",
|
f"select avg(c1) as int from {dbname}.t1",
|
||||||
"select avg from stb1",
|
f"select avg from {dbname}.stb1",
|
||||||
# "select avg(-+--+c1) from stb1",
|
# f"select avg(-+--+c1) from {dbname}.stb1",
|
||||||
# "select +-avg(c1) from stb1",
|
# f"select +-avg(c1) from {dbname}.stb1",
|
||||||
# "select ++-avg(c1) from stb1",
|
# f"select ++-avg(c1) from {dbname}.stb1",
|
||||||
# "select ++--avg(c1) from stb1",
|
# f"select ++--avg(c1) from {dbname}.stb1",
|
||||||
# "select - -avg(c1)*0 from stb1",
|
# f"select - -avg(c1)*0 from {dbname}.stb1",
|
||||||
# "select avg(tbname+1) from stb1 ",
|
# f"select avg(tbname+1) from {dbname}.stb1 ",
|
||||||
"select avg(123--123)==1 from stb1",
|
f"select avg(123--123)==1 from {dbname}.stb1",
|
||||||
"select avg(c1) as 'd1' from stb1",
|
f"select avg(c1) as 'd1' from {dbname}.stb1",
|
||||||
"select avg(c1 ,c2 ) from stb1",
|
f"select avg(c1 ,c2 ) from {dbname}.stb1",
|
||||||
"select avg(c1 ,NULL) from stb1",
|
f"select avg(c1 ,NULL) from {dbname}.stb1",
|
||||||
"select avg(,) from stb1;",
|
f"select avg(,) from {dbname}.stb1;",
|
||||||
"select avg(avg(c1) ab from stb1)",
|
f"select avg(avg(c1) ab from {dbname}.stb1)",
|
||||||
"select avg(c1) as int from stb1"
|
f"select avg(c1) as int from {dbname}.stb1"
|
||||||
]
|
]
|
||||||
for error_sql in error_sql_lists:
|
for error_sql in error_sql_lists:
|
||||||
tdSql.error(error_sql)
|
tdSql.error(error_sql)
|
||||||
|
|
||||||
def support_types(self):
|
def support_types(self, dbname="db"):
|
||||||
type_error_sql_lists = [
|
type_error_sql_lists = [
|
||||||
"select avg(ts) from t1" ,
|
f"select avg(ts) from {dbname}.t1" ,
|
||||||
"select avg(c7) from t1",
|
f"select avg(c7) from {dbname}.t1",
|
||||||
"select avg(c8) from t1",
|
f"select avg(c8) from {dbname}.t1",
|
||||||
"select avg(c9) from t1",
|
f"select avg(c9) from {dbname}.t1",
|
||||||
"select avg(ts) from ct1" ,
|
f"select avg(ts) from {dbname}.ct1" ,
|
||||||
"select avg(c7) from ct1",
|
f"select avg(c7) from {dbname}.ct1",
|
||||||
"select avg(c8) from ct1",
|
f"select avg(c8) from {dbname}.ct1",
|
||||||
"select avg(c9) from ct1",
|
f"select avg(c9) from {dbname}.ct1",
|
||||||
"select avg(ts) from ct3" ,
|
f"select avg(ts) from {dbname}.ct3" ,
|
||||||
"select avg(c7) from ct3",
|
f"select avg(c7) from {dbname}.ct3",
|
||||||
"select avg(c8) from ct3",
|
f"select avg(c8) from {dbname}.ct3",
|
||||||
"select avg(c9) from ct3",
|
f"select avg(c9) from {dbname}.ct3",
|
||||||
"select avg(ts) from ct4" ,
|
f"select avg(ts) from {dbname}.ct4" ,
|
||||||
"select avg(c7) from ct4",
|
f"select avg(c7) from {dbname}.ct4",
|
||||||
"select avg(c8) from ct4",
|
f"select avg(c8) from {dbname}.ct4",
|
||||||
"select avg(c9) from ct4",
|
f"select avg(c9) from {dbname}.ct4",
|
||||||
"select avg(ts) from stb1" ,
|
f"select avg(ts) from {dbname}.stb1" ,
|
||||||
"select avg(c7) from stb1",
|
f"select avg(c7) from {dbname}.stb1",
|
||||||
"select avg(c8) from stb1",
|
f"select avg(c8) from {dbname}.stb1",
|
||||||
"select avg(c9) from stb1" ,
|
f"select avg(c9) from {dbname}.stb1" ,
|
||||||
|
|
||||||
"select avg(ts) from stbbb1" ,
|
f"select avg(ts) from {dbname}.stbbb1" ,
|
||||||
"select avg(c7) from stbbb1",
|
f"select avg(c7) from {dbname}.stbbb1",
|
||||||
|
|
||||||
"select avg(ts) from tbname",
|
f"select avg(ts) from {dbname}.tbname",
|
||||||
"select avg(c9) from tbname"
|
f"select avg(c9) from {dbname}.tbname"
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -150,157 +151,157 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
type_sql_lists = [
|
type_sql_lists = [
|
||||||
"select avg(c1) from t1",
|
f"select avg(c1) from {dbname}.t1",
|
||||||
"select avg(c2) from t1",
|
f"select avg(c2) from {dbname}.t1",
|
||||||
"select avg(c3) from t1",
|
f"select avg(c3) from {dbname}.t1",
|
||||||
"select avg(c4) from t1",
|
f"select avg(c4) from {dbname}.t1",
|
||||||
"select avg(c5) from t1",
|
f"select avg(c5) from {dbname}.t1",
|
||||||
"select avg(c6) from t1",
|
f"select avg(c6) from {dbname}.t1",
|
||||||
|
|
||||||
"select avg(c1) from ct1",
|
f"select avg(c1) from {dbname}.ct1",
|
||||||
"select avg(c2) from ct1",
|
f"select avg(c2) from {dbname}.ct1",
|
||||||
"select avg(c3) from ct1",
|
f"select avg(c3) from {dbname}.ct1",
|
||||||
"select avg(c4) from ct1",
|
f"select avg(c4) from {dbname}.ct1",
|
||||||
"select avg(c5) from ct1",
|
f"select avg(c5) from {dbname}.ct1",
|
||||||
"select avg(c6) from ct1",
|
f"select avg(c6) from {dbname}.ct1",
|
||||||
|
|
||||||
"select avg(c1) from ct3",
|
f"select avg(c1) from {dbname}.ct3",
|
||||||
"select avg(c2) from ct3",
|
f"select avg(c2) from {dbname}.ct3",
|
||||||
"select avg(c3) from ct3",
|
f"select avg(c3) from {dbname}.ct3",
|
||||||
"select avg(c4) from ct3",
|
f"select avg(c4) from {dbname}.ct3",
|
||||||
"select avg(c5) from ct3",
|
f"select avg(c5) from {dbname}.ct3",
|
||||||
"select avg(c6) from ct3",
|
f"select avg(c6) from {dbname}.ct3",
|
||||||
|
|
||||||
"select avg(c1) from stb1",
|
f"select avg(c1) from {dbname}.stb1",
|
||||||
"select avg(c2) from stb1",
|
f"select avg(c2) from {dbname}.stb1",
|
||||||
"select avg(c3) from stb1",
|
f"select avg(c3) from {dbname}.stb1",
|
||||||
"select avg(c4) from stb1",
|
f"select avg(c4) from {dbname}.stb1",
|
||||||
"select avg(c5) from stb1",
|
f"select avg(c5) from {dbname}.stb1",
|
||||||
"select avg(c6) from stb1",
|
f"select avg(c6) from {dbname}.stb1",
|
||||||
|
|
||||||
"select avg(c6) as alisb from stb1",
|
f"select avg(c6) as alisb from {dbname}.stb1",
|
||||||
"select avg(c6) alisb from stb1",
|
f"select avg(c6) alisb from {dbname}.stb1",
|
||||||
]
|
]
|
||||||
|
|
||||||
for type_sql in type_sql_lists:
|
for type_sql in type_sql_lists:
|
||||||
tdSql.query(type_sql)
|
tdSql.query(type_sql)
|
||||||
|
|
||||||
def basic_avg_function(self):
|
def basic_avg_function(self, dbname="db"):
|
||||||
|
|
||||||
# basic query
|
# basic query
|
||||||
tdSql.query("select c1 from ct3")
|
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select c1 from t1")
|
tdSql.query(f"select c1 from {dbname}.t1")
|
||||||
tdSql.checkRows(12)
|
tdSql.checkRows(12)
|
||||||
tdSql.query("select c1 from stb1")
|
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
# used for empty table , ct3 is empty
|
# used for empty table , ct3 is empty
|
||||||
tdSql.query("select avg(c1) from ct3")
|
tdSql.query(f"select avg(c1) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select avg(c2) from ct3")
|
tdSql.query(f"select avg(c2) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select avg(c3) from ct3")
|
tdSql.query(f"select avg(c3) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select avg(c4) from ct3")
|
tdSql.query(f"select avg(c4) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select avg(c5) from ct3")
|
tdSql.query(f"select avg(c5) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select avg(c6) from ct3")
|
tdSql.query(f"select avg(c6) from {dbname}.ct3")
|
||||||
|
|
||||||
# used for regular table
|
# used for regular table
|
||||||
tdSql.query("select avg(c1) from t1")
|
tdSql.query(f"select avg(c1) from {dbname}.t1")
|
||||||
tdSql.checkData(0, 0, 5.000000000)
|
tdSql.checkData(0, 0, 5.000000000)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 5, 1.11000)
|
tdSql.checkData(1, 5, 1.11000)
|
||||||
tdSql.checkData(3, 4, 33)
|
tdSql.checkData(3, 4, 33)
|
||||||
tdSql.checkData(5, 5, None)
|
tdSql.checkData(5, 5, None)
|
||||||
self.check_avg(" select avg(c1) , avg(c2) , avg(c3) from t1 " , " select sum(c1)/count(c1) , sum(c2)/count(c2) , sum(c3)/count(c3) from t1 ")
|
self.check_avg(f" select avg(c1) , avg(c2) , avg(c3) from {dbname}.t1 " , f" select sum(c1)/count(c1) , sum(c2)/count(c2) , sum(c3)/count(c3) from {dbname}.t1 ")
|
||||||
|
|
||||||
# used for sub table
|
# used for sub table
|
||||||
tdSql.query("select avg(c1) from ct1")
|
tdSql.query(f"select avg(c1) from {dbname}.ct1")
|
||||||
tdSql.checkData(0, 0, 4.846153846)
|
tdSql.checkData(0, 0, 4.846153846)
|
||||||
|
|
||||||
tdSql.query("select avg(c1) from ct3")
|
tdSql.query(f"select avg(c1) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
self.check_avg(" select avg(abs(c1)) , avg(abs(c2)) , avg(abs(c3)) from t1 " , " select sum(abs(c1))/count(c1) , sum(abs(c2))/count(c2) , sum(abs(c3))/count(c3) from t1 ")
|
self.check_avg(f" select avg(abs(c1)) , avg(abs(c2)) , avg(abs(c3)) from {dbname}.t1 " , f" select sum(abs(c1))/count(c1) , sum(abs(c2))/count(c2) , sum(abs(c3))/count(c3) from {dbname}.t1 ")
|
||||||
self.check_avg(" select avg(abs(c1)) , avg(abs(c2)) , avg(abs(c3)) from stb1 " , " select sum(abs(c1))/count(c1) , sum(abs(c2))/count(c2) , sum(abs(c3))/count(c3) from stb1 ")
|
self.check_avg(f" select avg(abs(c1)) , avg(abs(c2)) , avg(abs(c3)) from {dbname}.stb1 " , f" select sum(abs(c1))/count(c1) , sum(abs(c2))/count(c2) , sum(abs(c3))/count(c3) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# used for stable table
|
# used for stable table
|
||||||
|
|
||||||
tdSql.query("select avg(c1) from stb1")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
self.check_avg(" select avg(abs(ceil(c1))) , avg(abs(ceil(c2))) , avg(abs(ceil(c3))) from stb1 " , " select sum(abs(ceil(c1)))/count(c1) , sum(abs(ceil(c2)))/count(c2) , sum(abs(ceil(c3)))/count(c3) from stb1 ")
|
self.check_avg(f" select avg(abs(ceil(c1))) , avg(abs(ceil(c2))) , avg(abs(ceil(c3))) from {dbname}.stb1 " , f" select sum(abs(ceil(c1)))/count(c1) , sum(abs(ceil(c2)))/count(c2) , sum(abs(ceil(c3)))/count(c3) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# used for not exists table
|
# used for not exists table
|
||||||
tdSql.error("select avg(c1) from stbbb1")
|
tdSql.error(f"select avg(c1) from {dbname}.stbbb1")
|
||||||
tdSql.error("select avg(c1) from tbname")
|
tdSql.error(f"select avg(c1) from {dbname}.tbname")
|
||||||
tdSql.error("select avg(c1) from ct5")
|
tdSql.error(f"select avg(c1) from {dbname}.ct5")
|
||||||
|
|
||||||
# mix with common col
|
# mix with common col
|
||||||
tdSql.error("select c1, avg(c1) from ct1")
|
tdSql.error(f"select c1, avg(c1) from {dbname}.ct1")
|
||||||
tdSql.error("select c1, avg(c1) from ct4")
|
tdSql.error(f"select c1, avg(c1) from {dbname}.ct4")
|
||||||
|
|
||||||
|
|
||||||
# mix with common functions
|
# mix with common functions
|
||||||
tdSql.error("select c1, avg(c1),c5, floor(c5) from ct4 ")
|
tdSql.error(f"select c1, avg(c1),c5, floor(c5) from {dbname}.ct4 ")
|
||||||
tdSql.error("select c1, avg(c1),c5, floor(c5) from stb1 ")
|
tdSql.error(f"select c1, avg(c1),c5, floor(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# mix with agg functions , not support
|
# mix with agg functions , not support
|
||||||
tdSql.error("select c1, avg(c1),c5, count(c5) from stb1 ")
|
tdSql.error(f"select c1, avg(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select c1, avg(c1),c5, count(c5) from ct1 ")
|
tdSql.error(f"select c1, avg(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from ct1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from stb1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# agg functions mix with agg functions
|
# agg functions mix with agg functions
|
||||||
|
|
||||||
tdSql.query(" select max(c5), count(c5) , avg(c5) from stb1 ")
|
tdSql.query(f" select max(c5), count(c5) , avg(c5) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0, 0, 8.88000 )
|
tdSql.checkData(0, 0, 8.88000 )
|
||||||
tdSql.checkData(0, 1, 22 )
|
tdSql.checkData(0, 1, 22 )
|
||||||
tdSql.checkData(0, 2, 2.270454591 )
|
tdSql.checkData(0, 2, 2.270454591 )
|
||||||
|
|
||||||
tdSql.query(" select max(c5), count(c5) , avg(c5) ,elapsed(ts) , spread(c1) from ct1; ")
|
tdSql.query(f" select max(c5), count(c5) , avg(c5) ,elapsed(ts) , spread(c1) from {dbname}.ct1; ")
|
||||||
tdSql.checkData(0, 0, 8.88000 )
|
tdSql.checkData(0, 0, 8.88000 )
|
||||||
tdSql.checkData(0, 1, 13 )
|
tdSql.checkData(0, 1, 13 )
|
||||||
tdSql.checkData(0, 2, 0.768461603 )
|
tdSql.checkData(0, 2, 0.768461603 )
|
||||||
|
|
||||||
# bug fix for count
|
# bug fix for count
|
||||||
tdSql.query("select count(c1) from ct4 ")
|
tdSql.query(f"select count(c1) from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0,0,9)
|
tdSql.checkData(0,0,9)
|
||||||
tdSql.query("select count(*) from ct4 ")
|
tdSql.query(f"select count(*) from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0,0,12)
|
tdSql.checkData(0,0,12)
|
||||||
tdSql.query("select count(c1) from stb1 ")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0,0,22)
|
tdSql.checkData(0,0,22)
|
||||||
tdSql.query("select count(*) from stb1 ")
|
tdSql.query(f"select count(*) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0,0,25)
|
tdSql.checkData(0,0,25)
|
||||||
|
|
||||||
# bug fix for compute
|
# bug fix for compute
|
||||||
tdSql.error("select c1, avg(c1) -0 ,ceil(c1)-0 from ct4 ")
|
tdSql.error(f"select c1, avg(c1) -0 ,ceil(c1)-0 from {dbname}.ct4 ")
|
||||||
tdSql.error(" select c1, avg(c1) -0 ,avg(ceil(c1-0.1))-0.1 from ct4")
|
tdSql.error(f" select c1, avg(c1) -0 ,avg(ceil(c1-0.1))-0.1 from {dbname}.ct4")
|
||||||
|
|
||||||
# mix with nest query
|
# mix with nest query
|
||||||
self.check_avg("select avg(col) from (select abs(c1) col from stb1)" , "select avg(abs(c1)) from stb1")
|
self.check_avg(f"select avg(col) from (select abs(c1) col from {dbname}.stb1)" , f"select avg(abs(c1)) from {dbname}.stb1")
|
||||||
self.check_avg("select avg(col) from (select ceil(abs(c1)) col from stb1)" , "select avg(abs(c1)) from stb1")
|
self.check_avg(f"select avg(col) from (select ceil(abs(c1)) col from {dbname}.stb1)" , f"select avg(abs(c1)) from {dbname}.stb1")
|
||||||
|
|
||||||
tdSql.query(" select abs(avg(abs(abs(c1)))) from stb1 ")
|
tdSql.query(f" select abs(avg(abs(abs(c1)))) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0, 0, 4.500000000)
|
tdSql.checkData(0, 0, 4.500000000)
|
||||||
tdSql.query(" select abs(avg(abs(abs(c1)))) from t1 ")
|
tdSql.query(f" select abs(avg(abs(abs(c1)))) from {dbname}.t1 ")
|
||||||
tdSql.checkData(0, 0, 5.000000000)
|
tdSql.checkData(0, 0, 5.000000000)
|
||||||
|
|
||||||
tdSql.query(" select abs(avg(abs(abs(c1)))) from stb1 ")
|
tdSql.query(f" select abs(avg(abs(abs(c1)))) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0, 0, 4.500000000)
|
tdSql.checkData(0, 0, 4.500000000)
|
||||||
|
|
||||||
tdSql.query(" select avg(c1) from stb1 where c1 is null ")
|
tdSql.query(f" select avg(c1) from {dbname}.stb1 where c1 is null ")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
|
||||||
def avg_func_filter(self):
|
def avg_func_filter(self, dbname="db"):
|
||||||
tdSql.execute("use db")
|
tdSql.execute(f"use {dbname}")
|
||||||
tdSql.query(" select avg(c1), avg(c1) -0 ,avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2)-0.5)) from ct4 where c1>5 ")
|
tdSql.query(f" select avg(c1), avg(c1) -0 ,avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2)-0.5)) from {dbname}.ct4 where c1>5 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,7.000000000)
|
tdSql.checkData(0,0,7.000000000)
|
||||||
tdSql.checkData(0,1,7.000000000)
|
tdSql.checkData(0,1,7.000000000)
|
||||||
|
@ -308,7 +309,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,6.900000000)
|
tdSql.checkData(0,3,6.900000000)
|
||||||
tdSql.checkData(0,4,3.000000000)
|
tdSql.checkData(0,4,3.000000000)
|
||||||
|
|
||||||
tdSql.query("select avg(c1), avg(c1) -0 ,avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2)-0.5)) from ct4 where c1=5 ")
|
tdSql.query(f"select avg(c1), avg(c1) -0 ,avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2)-0.5)) from {dbname}.ct4 where c1=5 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,5.000000000)
|
tdSql.checkData(0,0,5.000000000)
|
||||||
tdSql.checkData(0,1,5.000000000)
|
tdSql.checkData(0,1,5.000000000)
|
||||||
|
@ -316,59 +317,56 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,4.900000000)
|
tdSql.checkData(0,3,4.900000000)
|
||||||
tdSql.checkData(0,4,2.000000000)
|
tdSql.checkData(0,4,2.000000000)
|
||||||
|
|
||||||
tdSql.query("select avg(c1) ,avg(c2) , avg(c1) -0 , avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2))-0.5) from ct4 where c1>log(c1,2) limit 1 ")
|
tdSql.query(f"select avg(c1) ,avg(c2) , avg(c1) -0 , avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2))-0.5) from {dbname}.ct4 where c1>log(c1,2) limit 1 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0, 0, 4.500000000)
|
tdSql.checkData(0, 0, 4.500000000)
|
||||||
tdSql.checkData(0, 1, 49999.500000000)
|
tdSql.checkData(0, 1, 49999.500000000)
|
||||||
tdSql.checkData(0, 5, 1.625000000)
|
tdSql.checkData(0, 5, 1.625000000)
|
||||||
|
|
||||||
def avg_Arithmetic(self):
|
def check_boundary_values(self, dbname="bound_test"):
|
||||||
pass
|
|
||||||
|
|
||||||
def check_boundary_values(self):
|
tdSql.execute(f"drop database if exists {dbname}")
|
||||||
|
tdSql.execute(f"create database if not exists {dbname}")
|
||||||
tdSql.execute("drop database if exists bound_test")
|
|
||||||
tdSql.execute("create database if not exists bound_test")
|
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
tdSql.execute("use bound_test")
|
tdSql.execute(f"use {dbname}")
|
||||||
tdSql.execute(
|
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(
|
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(
|
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(
|
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(
|
tdSql.execute(
|
||||||
f"insert into sub1_bound values ( now(), 2147483645, 9223372036854775805, 32765, 125, 3.40E+37, 1.7e+307, True, 'binary_tb1', 'nchar_tb1', now() )"
|
f"insert into {dbname}.sub1_bound values ( now(), 2147483645, 9223372036854775805, 32765, 125, 3.40E+37, 1.7e+307, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into sub1_bound values ( now(), 2147483644, 9223372036854775804, 32764, 124, 3.40E+37, 1.7e+307, True, 'binary_tb1', 'nchar_tb1', now() )"
|
f"insert into {dbname}.sub1_bound values ( now(), 2147483644, 9223372036854775804, 32764, 124, 3.40E+37, 1.7e+307, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
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(
|
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(
|
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_avg("select avg(c1), avg(c2), avg(c3) , avg(c4), avg(c5) ,avg(c6) from sub1_bound " , " select sum(c1)/count(c1), sum(c2)/count(c2) ,sum(c3)/count(c3), sum(c4)/count(c4), sum(c5)/count(c5) ,sum(c6)/count(c6) from sub1_bound ")
|
self.check_avg(f"select avg(c1), avg(c2), avg(c3) , avg(c4), avg(c5) ,avg(c6) from {dbname}.sub1_bound " , f" select sum(c1)/count(c1), sum(c2)/count(c2) ,sum(c3)/count(c3), sum(c4)/count(c4), sum(c5)/count(c5) ,sum(c6)/count(c6) from {dbname}.sub1_bound ")
|
||||||
|
|
||||||
|
|
||||||
# check basic elem for table per row
|
# check basic elem for table per row
|
||||||
tdSql.query("select avg(c1) ,avg(c2) , avg(c3) , avg(c4), avg(c5), avg(c6) from sub1_bound ")
|
tdSql.query(f"select avg(c1) ,avg(c2) , avg(c3) , avg(c4), avg(c5), avg(c6) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,920350133.571428537)
|
tdSql.checkData(0,0,920350133.571428537)
|
||||||
tdSql.checkData(0,1,1.3176245766935393e+18)
|
tdSql.checkData(0,1,1.3176245766935393e+18)
|
||||||
|
@ -379,7 +377,7 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
# check + - * / in functions
|
# check + - * / in functions
|
||||||
tdSql.query(" select avg(c1+1) ,avg(c2) , avg(c3*1) , avg(c4/2), avg(c5)/2, avg(c6) from sub1_bound ")
|
tdSql.query(f" select avg(c1+1) ,avg(c2) , avg(c3*1) , avg(c4/2), avg(c5)/2, avg(c6) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,920350134.5714285)
|
tdSql.checkData(0,0,920350134.5714285)
|
||||||
tdSql.checkData(0,1,1.3176245766935393e+18)
|
tdSql.checkData(0,1,1.3176245766935393e+18)
|
||||||
tdSql.checkData(0,2,14042.142857143)
|
tdSql.checkData(0,2,14042.142857143)
|
||||||
|
|
|
@ -13,190 +13,195 @@ class TDTestCase:
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
def run(self): # sourcery skip: extract-duplicate-method
|
def run(self):
|
||||||
|
dbname = "db"
|
||||||
|
stb = f"{dbname}.stb1"
|
||||||
|
rows = 10
|
||||||
|
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table if not exists supt
|
f'''create table if not exists {stb}
|
||||||
(ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint)
|
(ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint)
|
||||||
tags(location binary(64), type int, isused bool , family nchar(64))'''
|
tags(location binary(64), type int, isused bool , family nchar(64))'''
|
||||||
)
|
)
|
||||||
tdSql.execute("create table t1 using supt tags('beijing', 1, 1, 'nchar1')")
|
tdSql.execute(f"create table {dbname}.t1 using {stb} tags('beijing', 1, 1, 'nchar1')")
|
||||||
tdSql.execute("create table t2 using supt tags('shanghai', 2, 0, 'nchar2')")
|
tdSql.execute(f"create table {dbname}.t2 using {stb} tags('shanghai', 2, 0, 'nchar2')")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
tdLog.printNoPrefix("==========step2:insert data")
|
||||||
for i in range(10):
|
for i in range(rows):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into t1 values (now()+{i}m, {32767+i}, {20.0+i/10}, {2**31+i}, {3.4*10**38+i/10}, {127+i}, {i})"
|
f"insert into {dbname}.t1 values (now()+{i}m, {32767+i}, {20.0+i/10}, {2**31+i}, {3.4*10**38+i/10}, {127+i}, {i})"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into t2 values (now()-{i}m, {-32767-i}, {20.0-i/10}, {-i-2**31}, {-i/10-3.4*10**38}, {-127-i}, {-i})"
|
f"insert into {dbname}.t2 values (now()-{i}m, {-32767-i}, {20.0-i/10}, {-i-2**31}, {-i/10-3.4*10**38}, {-127-i}, {-i})"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into t1 values (now()+11m, {2**31-1}, {pow(10,37)*34}, {pow(2,63)-1}, {1.7*10**308}, 32767, 127)"
|
f"insert into {dbname}.t1 values (now()+11m, {2**31-1}, {pow(10,37)*34}, {pow(2,63)-1}, {1.7*10**308}, 32767, 127)"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into t2 values (now()-11m, {1-2**31}, {-3.4*10**38}, {1-2**63}, {-1.7*10**308}, -32767, -127)"
|
f"insert into {dbname}.t2 values (now()-11m, {1-2**31}, {-3.4*10**38}, {1-2**63}, {-1.7*10**308}, -32767, -127)"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into t2 values (now()-12m, null , {-3.4*10**38}, null , {-1.7*10**308}, null , null)"
|
f"insert into {dbname}.t2 values (now()-12m, null , {-3.4*10**38}, null , {-1.7*10**308}, null , null)"
|
||||||
)
|
)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step3:query timestamp type")
|
tdLog.printNoPrefix("==========step3:query timestamp type")
|
||||||
|
|
||||||
tdSql.query("select * from t1 where ts between now()-1m and now()+10m")
|
tdSql.query(f"select * from {dbname}.t1 where ts between now()-1m and now()+10m")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query("select * from t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'")
|
tdSql.query(f"select * from {dbname}.t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'")
|
||||||
# tdSql.checkRows(11)
|
# tdSql.checkRows(11)
|
||||||
tdSql.query("select * from t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'")
|
tdSql.query(f"select * from {dbname}.t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'")
|
||||||
# tdSql.checkRows(0)
|
# tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where ts between -2793600 and 31507199")
|
tdSql.query(f"select * from {dbname}.t1 where ts between -2793600 and 31507199")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where ts between 1609430400000 and 4765104000000")
|
tdSql.query(f"select * from {dbname}.t1 where ts between 1609430400000 and 4765104000000")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(rows+1)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4:query int type")
|
tdLog.printNoPrefix("==========step4:query int type")
|
||||||
|
|
||||||
tdSql.query("select * from t1 where c1 between 32767 and 32776")
|
tdSql.query(f"select * from {dbname}.t1 where c1 between 32767 and 32776")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query("select * from t1 where c1 between 32766.9 and 32776.1")
|
tdSql.query(f"select * from {dbname}.t1 where c1 between 32766.9 and 32776.1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query("select * from t1 where c1 between 32776 and 32767")
|
tdSql.query(f"select * from {dbname}.t1 where c1 between 32776 and 32767")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c1 between 'a' and 'e'")
|
tdSql.query(f"select * from {dbname}.t1 where c1 between 'a' and 'e'")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
# tdSql.query("select * from t1 where c1 between 0x64 and 0x69")
|
# tdSql.query("select * from {dbname}.t1 where c1 between 0x64 and 0x69")
|
||||||
# tdSql.checkRows(6)
|
# tdSql.checkRows(6)
|
||||||
tdSql.query("select * from t1 where c1 not between 100 and 106")
|
tdSql.query(f"select * from {dbname}.t1 where c1 not between 100 and 106")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(rows+1)
|
||||||
tdSql.query(f"select * from t1 where c1 between {2**31-2} and {2**31+1}")
|
tdSql.query(f"select * from {dbname}.t1 where c1 between {2**31-2} and {2**31+1}")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query(f"select * from t2 where c1 between null and {1-2**31}")
|
tdSql.query(f"select * from {dbname}.t2 where c1 between null and {1-2**31}")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
tdSql.query(f"select * from t2 where c1 between {-2**31} and {1-2**31}")
|
tdSql.query(f"select * from {dbname}.t2 where c1 between {-2**31} and {1-2**31}")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step5:query float type")
|
tdLog.printNoPrefix("==========step5:query float type")
|
||||||
|
|
||||||
tdSql.query("select * from t1 where c2 between 20.0 and 21.0")
|
tdSql.query(f"select * from {dbname}.t1 where c2 between 20.0 and 21.0")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
tdSql.query(f"select * from t1 where c2 between {-3.4*10**38-1} and {3.4*10**38+1}")
|
tdSql.query(f"select * from {dbname}.t1 where c2 between {-3.4*10**38-1} and {3.4*10**38+1}")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(rows+1)
|
||||||
tdSql.query("select * from t1 where c2 between 21.0 and 20.0")
|
tdSql.query(f"select * from {dbname}.t1 where c2 between 21.0 and 20.0")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c2 between 'DC3' and 'SYN'")
|
tdSql.query(f"select * from {dbname}.t1 where c2 between 'DC3' and 'SYN'")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c2 not between 0.1 and 0.2")
|
tdSql.query(f"select * from {dbname}.t1 where c2 not between 0.1 and 0.2")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(rows+1)
|
||||||
tdSql.query(f"select * from t1 where c2 between {pow(10,38)*3.4} and {pow(10,38)*3.4+1}")
|
tdSql.query(f"select * from {dbname}.t1 where c2 between {pow(10,38)*3.4} and {pow(10,38)*3.4+1}")
|
||||||
# tdSql.checkRows(1)
|
# tdSql.checkRows(1)
|
||||||
tdSql.query(f"select * from t2 where c2 between {-3.4*10**38-1} and {-3.4*10**38}")
|
tdSql.query(f"select * from {dbname}.t2 where c2 between {-3.4*10**38-1} and {-3.4*10**38}")
|
||||||
# tdSql.checkRows(2)
|
# tdSql.checkRows(2)
|
||||||
tdSql.query(f"select * from t2 where c2 between null and {-3.4*10**38}")
|
tdSql.query(f"select * from {dbname}.t2 where c2 between null and {-3.4*10**38}")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step6:query bigint type")
|
tdLog.printNoPrefix("==========step6:query bigint type")
|
||||||
|
|
||||||
tdSql.query(f"select * from t1 where c3 between {2**31} and {2**31+10}")
|
tdSql.query(f"select * from {dbname}.t1 where c3 between {2**31} and {2**31+10}")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query(f"select * from t1 where c3 between {-2**63} and {2**63}")
|
tdSql.query(f"select * from {dbname}.t1 where c3 between {-2**63} and {2**63}")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(rows+1)
|
||||||
tdSql.query(f"select * from t1 where c3 between {2**31+10} and {2**31}")
|
tdSql.query(f"select * from {dbname}.t1 where c3 between {2**31+10} and {2**31}")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c3 between 'a' and 'z'")
|
tdSql.query(f"select * from {dbname}.t1 where c3 between 'a' and 'z'")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c3 not between 1 and 2")
|
tdSql.query(f"select * from {dbname}.t1 where c3 not between 1 and 2")
|
||||||
# tdSql.checkRows(0)
|
# tdSql.checkRows(0)
|
||||||
tdSql.query(f"select * from t1 where c3 between {2**63-2} and {2**63-1}")
|
tdSql.query(f"select * from {dbname}.t1 where c3 between {2**63-2} and {2**63-1}")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query(f"select * from t2 where c3 between {-2**63} and {1-2**63}")
|
tdSql.query(f"select * from {dbname}.t2 where c3 between {-2**63} and {1-2**63}")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
tdSql.query(f"select * from t2 where c3 between null and {1-2**63}")
|
tdSql.query(f"select * from {dbname}.t2 where c3 between null and {1-2**63}")
|
||||||
# tdSql.checkRows(2)
|
# tdSql.checkRows(2)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step7:query double type")
|
tdLog.printNoPrefix("==========step7:query double type")
|
||||||
|
|
||||||
tdSql.query(f"select * from t1 where c4 between {3.4*10**38} and {3.4*10**38+10}")
|
tdSql.query(f"select * from {dbname}.t1 where c4 between {3.4*10**38} and {3.4*10**38+10}")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query(f"select * from t1 where c4 between {1.7*10**308+1} and {1.7*10**308+2}")
|
tdSql.query(f"select * from {dbname}.t1 where c4 between {1.7*10**308+1} and {1.7*10**308+2}")
|
||||||
# 因为精度原因,在超出bigint边界后,数值不能进行准确的判断
|
# 因为精度原因,在超出bigint边界后,数值不能进行准确的判断
|
||||||
# tdSql.checkRows(0)
|
# tdSql.checkRows(0)
|
||||||
tdSql.query(f"select * from t1 where c4 between {3.4*10**38+10} and {3.4*10**38}")
|
tdSql.query(f"select * from {dbname}.t1 where c4 between {3.4*10**38+10} and {3.4*10**38}")
|
||||||
# tdSql.checkRows(0)
|
# tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c4 between 'a' and 'z'")
|
tdSql.query(f"select * from {dbname}.t1 where c4 between 'a' and 'z'")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c4 not between 1 and 2")
|
tdSql.query(f"select * from {dbname}.t1 where c4 not between 1 and 2")
|
||||||
# tdSql.checkRows(0)
|
# tdSql.checkRows(0)
|
||||||
tdSql.query(f"select * from t1 where c4 between {1.7*10**308} and {1.7*10**308+1}")
|
tdSql.query(f"select * from {dbname}.t1 where c4 between {1.7*10**308} and {1.7*10**308+1}")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query(f"select * from t2 where c4 between {-1.7*10**308-1} and {-1.7*10**308}")
|
tdSql.query(f"select * from {dbname}.t2 where c4 between {-1.7*10**308-1} and {-1.7*10**308}")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
tdSql.query(f"select * from t2 where c4 between null and {-1.7*10**308}")
|
tdSql.query(f"select * from {dbname}.t2 where c4 between null and {-1.7*10**308}")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step8:query smallint type")
|
tdLog.printNoPrefix("==========step8:query smallint type")
|
||||||
|
|
||||||
tdSql.query("select * from t1 where c5 between 127 and 136")
|
tdSql.query(f"select * from {dbname}.t1 where c5 between 127 and 136")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query("select * from t1 where c5 between 126.9 and 135.9")
|
tdSql.query(f"select * from {dbname}.t1 where c5 between 126.9 and 135.9")
|
||||||
tdSql.checkRows(9)
|
tdSql.checkRows(rows-1)
|
||||||
tdSql.query("select * from t1 where c5 between 136 and 127")
|
tdSql.query(f"select * from {dbname}.t1 where c5 between 136 and 127")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c5 between '~' and '^'")
|
tdSql.query(f"select * from {dbname}.t1 where c5 between '~' and '^'")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c5 not between 1 and 2")
|
tdSql.query(f"select * from {dbname}.t1 where c5 not between 1 and 2")
|
||||||
# tdSql.checkRows(0)
|
# tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c5 between 32767 and 32768")
|
tdSql.query(f"select * from {dbname}.t1 where c5 between 32767 and 32768")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query("select * from t2 where c5 between -32768 and -32767")
|
tdSql.query(f"select * from {dbname}.t2 where c5 between -32768 and -32767")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query("select * from t2 where c5 between null and -32767")
|
tdSql.query(f"select * from {dbname}.t2 where c5 between null and -32767")
|
||||||
# tdSql.checkRows(1)
|
# tdSql.checkRows(1)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step9:query tinyint type")
|
tdLog.printNoPrefix("==========step9:query tinyint type")
|
||||||
|
|
||||||
tdSql.query("select * from t1 where c6 between 0 and 9")
|
tdSql.query(f"select * from {dbname}.t1 where c6 between 0 and 9")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
tdSql.query("select * from t1 where c6 between -1.1 and 8.9")
|
tdSql.query(f"select * from {dbname}.t1 where c6 between -1.1 and 8.9")
|
||||||
tdSql.checkRows(9)
|
tdSql.checkRows(rows-1)
|
||||||
tdSql.query("select * from t1 where c6 between 9 and 0")
|
tdSql.query(f"select * from {dbname}.t1 where c6 between 9 and 0")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select * from t1 where c6 between 'NUL' and 'HT'")
|
tdSql.query(f"select * from {dbname}.t1 where c6 between 'NUL' and 'HT'")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query("select * from t1 where c6 not between 1 and 2")
|
tdSql.query(f"select * from {dbname}.t1 where c6 not between 1 and 2")
|
||||||
# tdSql.checkRows(1)
|
# tdSql.checkRows(1)
|
||||||
tdSql.query("select * from t1 where c6 between 127 and 128")
|
tdSql.query(f"select * from {dbname}.t1 where c6 between 127 and 128")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query("select * from t2 where c6 between -128 and -127")
|
tdSql.query(f"select * from {dbname}.t2 where c6 between -128 and -127")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query("select * from t2 where c6 between null and -127")
|
tdSql.query(f"select * from {dbname}.t2 where c6 between null and -127")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step10:invalid query type")
|
tdLog.printNoPrefix("==========step10:invalid query type")
|
||||||
|
|
||||||
# TODO tag is not finished
|
# TODO tag is not finished
|
||||||
# tdSql.query("select * from supt where location between 'beijing' and 'shanghai'")
|
tdSql.query(f"select * from {stb} where location between 'beijing' and 'shanghai'")
|
||||||
# tdSql.checkRows(23)
|
tdSql.checkRows(rows * 2 + 3)
|
||||||
# # 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0"
|
# 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0"
|
||||||
# tdSql.query("select * from supt where isused between 0 and 1")
|
tdSql.query(f"select * from {stb} where isused between 0 and 1")
|
||||||
# tdSql.checkRows(23)
|
tdSql.checkRows(rows * 2 + 3)
|
||||||
# tdSql.query("select * from supt where isused between -1 and 0")
|
tdSql.query(f"select * from {stb} where isused between -1 and 0")
|
||||||
# tdSql.checkRows(0)
|
tdSql.checkRows(rows + 2)
|
||||||
# tdSql.error("select * from supt where isused between false and true")
|
tdSql.query(f"select * from {stb} where isused between false and true")
|
||||||
# tdSql.query("select * from supt where family between '拖拉机' and '自行车'")
|
tdSql.checkRows(rows * 2 + 3)
|
||||||
# tdSql.checkRows(23)
|
tdSql.query(f"select * from {stb} where family between '拖拉机' and '自行车'")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step11:query HEX/OCT/BIN type")
|
tdLog.printNoPrefix("==========step11:query HEX/OCT/BIN type")
|
||||||
|
|
||||||
tdSql.error("select * from t1 where c6 between 0x7f and 0x80") # check filter HEX
|
tdSql.error(f"select * from {dbname}.t1 where c6 between 0x7f and 0x80") # check filter HEX
|
||||||
tdSql.error("select * from t1 where c6 between 0b1 and 0b11111") # check filter BIN
|
tdSql.error(f"select * from {dbname}.t1 where c6 between 0b1 and 0b11111") # check filter BIN
|
||||||
tdSql.error("select * from t1 where c6 between 0b1 and 0x80")
|
tdSql.error(f"select * from {dbname}.t1 where c6 between 0b1 and 0x80")
|
||||||
tdSql.error("select * from t1 where c6=0b1")
|
tdSql.error(f"select * from {dbname}.t1 where c6=0b1")
|
||||||
tdSql.error("select * from t1 where c6=0x1")
|
tdSql.error(f"select * from {dbname}.t1 where c6=0x1")
|
||||||
# 八进制数据会按照十进制数据进行判定
|
# 八进制数据会按照十进制数据进行判定
|
||||||
tdSql.query("select * from t1 where c6 between 01 and 0200") # check filter OCT
|
tdSql.query(f"select * from {dbname}.t1 where c6 between 01 and 0200") # check filter OCT
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(rows)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TDTestCase:
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
self.dbname = 'db_test'
|
self.dbname = 'db_test'
|
||||||
self.setsql = TDSetSql()
|
self.setsql = TDSetSql()
|
||||||
self.ntbname = 'ntb'
|
self.ntbname = f'{self.dbname}.ntb'
|
||||||
self.rowNum = 10
|
self.rowNum = 10
|
||||||
self.tbnum = 20
|
self.tbnum = 20
|
||||||
self.ts = 1537146000000
|
self.ts = 1537146000000
|
||||||
|
@ -96,7 +96,7 @@ class TDTestCase:
|
||||||
self.bottom_check_data(self.ntbname,'normal_table')
|
self.bottom_check_data(self.ntbname,'normal_table')
|
||||||
tdSql.execute(f'drop database {self.dbname}')
|
tdSql.execute(f'drop database {self.dbname}')
|
||||||
def bottom_check_stb(self):
|
def bottom_check_stb(self):
|
||||||
stbname = tdCom.getLongName(5, "letters")
|
stbname = f'{self.dbname}.{tdCom.getLongName(5, "letters")}'
|
||||||
tag_dict = {
|
tag_dict = {
|
||||||
't0':'int'
|
't0':'int'
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class TDTestCase:
|
||||||
for i in range(self.tbnum):
|
for i in range(self.tbnum):
|
||||||
tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})")
|
tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})")
|
||||||
self.insert_data(self.column_dict,f'{stbname}_{i}',self.rowNum)
|
self.insert_data(self.column_dict,f'{stbname}_{i}',self.rowNum)
|
||||||
tdSql.query('show tables')
|
tdSql.query(f'show {self.dbname}.tables')
|
||||||
vgroup_list = []
|
vgroup_list = []
|
||||||
for i in range(len(tdSql.queryResult)):
|
for i in range(len(tdSql.queryResult)):
|
||||||
vgroup_list.append(tdSql.queryResult[i][6])
|
vgroup_list.append(tdSql.queryResult[i][6])
|
||||||
|
|
|
@ -15,6 +15,7 @@ class TDTestCase:
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
self.dbname = "db"
|
||||||
|
|
||||||
def __cast_to_bigint(self, col_name, tbname):
|
def __cast_to_bigint(self, col_name, tbname):
|
||||||
__sql = f"select cast({col_name} as bigint), {col_name} from {tbname}"
|
__sql = f"select cast({col_name} as bigint), {col_name} from {tbname}"
|
||||||
|
@ -35,7 +36,7 @@ class TDTestCase:
|
||||||
for i in range(tdSql.queryRows):
|
for i in range(tdSql.queryRows):
|
||||||
if data_tb_col[i] is None:
|
if data_tb_col[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
if col_name not in ["c2", "double"] or tbname != "t1" or i != 10:
|
if col_name not in ["c2", "double"] or tbname != f"{self.dbname}.t1" or i != 10:
|
||||||
utc_zone = datetime.timezone.utc
|
utc_zone = datetime.timezone.utc
|
||||||
utc_8 = datetime.timezone(datetime.timedelta(hours=8))
|
utc_8 = datetime.timezone(datetime.timedelta(hours=8))
|
||||||
date_init_stamp = datetime.datetime.utcfromtimestamp(data_tb_col[i]/1000)
|
date_init_stamp = datetime.datetime.utcfromtimestamp(data_tb_col[i]/1000)
|
||||||
|
@ -48,52 +49,52 @@ class TDTestCase:
|
||||||
self.__cast_to_timestamp(col_name=col, tbname=table)
|
self.__cast_to_timestamp(col_name=col, tbname=table)
|
||||||
|
|
||||||
def __test_bigint(self):
|
def __test_bigint(self):
|
||||||
__table_list = ["ct1", "ct4", "t1"]
|
__table_list = [f"{self.dbname}.ct1", f"{self.dbname}.ct4", f"{self.dbname}.t1"]
|
||||||
__col_list = ["c1","c2","c3","c4","c5","c6","c7","c10","c1+c2"]
|
__col_list = ["c1","c2","c3","c4","c5","c6","c7","c10","c1+c2"]
|
||||||
self.__range_to_bigint(cols=__col_list, tables=__table_list)
|
self.__range_to_bigint(cols=__col_list, tables=__table_list)
|
||||||
|
|
||||||
def __test_timestamp(self):
|
def __test_timestamp(self):
|
||||||
__table_list = ["ct1", "ct4", "t1"]
|
__table_list = [f"{self.dbname}.ct1", f"{self.dbname}.ct4", f"{self.dbname}.t1"]
|
||||||
__col_list = ["c1","c2","c3","c4","c5","c6","c7","c1+c2"]
|
__col_list = ["c1","c2","c3","c4","c5","c6","c7","c1+c2"]
|
||||||
self.__range_to_timestamp(cols=__col_list, tables=__table_list)
|
self.__range_to_timestamp(cols=__col_list, tables=__table_list)
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self):
|
||||||
|
|
||||||
tdSql.query("select c1 from ct4")
|
tdSql.query(f"select c1 from {self.dbname}.ct4")
|
||||||
data_ct4_c1 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c1 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c1 from t1")
|
tdSql.query(f"select c1 from {self.dbname}.t1")
|
||||||
data_t1_c1 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c1 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2: cast int to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step2: cast int to bigint, expect no changes")
|
||||||
|
|
||||||
tdSql.query("select cast(c1 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c1 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c1)):
|
for i in range(len(data_ct4_c1)):
|
||||||
tdSql.checkData( i, 0, data_ct4_c1[i])
|
tdSql.checkData( i, 0, data_ct4_c1[i])
|
||||||
tdSql.query("select cast(c1 as bigint) as b from t1")
|
tdSql.query(f"select cast(c1 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c1)):
|
for i in range(len(data_t1_c1)):
|
||||||
tdSql.checkData( i, 0, data_t1_c1[i])
|
tdSql.checkData( i, 0, data_t1_c1[i])
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step5: cast int to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step5: cast int to binary, expect changes to str(int) ")
|
||||||
|
|
||||||
#tdSql.query("select cast(c1 as binary(32)) as b from ct4")
|
#tdSql.query(f"select cast(c1 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
#for i in range(len(data_ct4_c1)):
|
#for i in range(len(data_ct4_c1)):
|
||||||
# tdSql.checkData( i, 0, str(data_ct4_c1[i]) )
|
# tdSql.checkData( i, 0, str(data_ct4_c1[i]) )
|
||||||
tdSql.query("select cast(c1 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c1 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c1)):
|
for i in range(len(data_t1_c1)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step6: cast int to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step6: cast int to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c1 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c1 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c1)):
|
for i in range(len(data_ct4_c1)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c1[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c1[i]) )
|
||||||
tdSql.query("select cast(c1 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c1 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c1)):
|
for i in range(len(data_t1_c1)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step7: cast int to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step7: cast int to timestamp, expect changes to timestamp ")
|
||||||
|
|
||||||
tdSql.query("select cast(c1 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c1 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c1)):
|
for i in range(len(data_ct4_c1)):
|
||||||
if data_ct4_c1[i] is None:
|
if data_ct4_c1[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -104,7 +105,7 @@ class TDTestCase:
|
||||||
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
tdSql.query("select cast(c1 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c1 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c1)):
|
for i in range(len(data_t1_c1)):
|
||||||
if data_ct4_c1[i] is None:
|
if data_ct4_c1[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -117,40 +118,40 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step8: cast bigint to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step8: cast bigint to bigint, expect no changes")
|
||||||
tdSql.query("select c2 from ct4")
|
tdSql.query(f"select c2 from {self.dbname}.ct4")
|
||||||
data_ct4_c2 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c2 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c2 from t1")
|
tdSql.query(f"select c2 from {self.dbname}.t1")
|
||||||
data_t1_c2 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c2 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdSql.query("select cast(c2 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c2 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c2)):
|
for i in range(len(data_ct4_c2)):
|
||||||
tdSql.checkData( i, 0, data_ct4_c2[i])
|
tdSql.checkData( i, 0, data_ct4_c2[i])
|
||||||
tdSql.query("select cast(c2 as bigint) as b from t1")
|
tdSql.query(f"select cast(c2 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c2)):
|
for i in range(len(data_t1_c2)):
|
||||||
tdSql.checkData( i, 0, data_t1_c2[i])
|
tdSql.checkData( i, 0, data_t1_c2[i])
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step9: cast bigint to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step9: cast bigint to binary, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c2 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c2 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c2)):
|
for i in range(len(data_ct4_c2)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c2[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c2[i]) )
|
||||||
tdSql.query("select cast(c2 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c2 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c2)):
|
for i in range(len(data_t1_c2)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step10: cast bigint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step10: cast bigint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c2 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c2 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c2)):
|
for i in range(len(data_ct4_c2)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c2[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c2[i]) )
|
||||||
tdSql.query("select cast(c2 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c2 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c2)):
|
for i in range(len(data_t1_c2)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step11: cast bigint to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step11: cast bigint to timestamp, expect changes to timestamp ")
|
||||||
|
|
||||||
tdSql.query("select cast(c2 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c2 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c2)):
|
for i in range(len(data_ct4_c2)):
|
||||||
if data_ct4_c2[i] is None:
|
if data_ct4_c2[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -162,7 +163,7 @@ class TDTestCase:
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select cast(c2 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c2 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c2)):
|
for i in range(len(data_t1_c2)):
|
||||||
if data_t1_c2[i] is None:
|
if data_t1_c2[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -177,40 +178,40 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step12: cast smallint to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step12: cast smallint to bigint, expect no changes")
|
||||||
tdSql.query("select c3 from ct4")
|
tdSql.query(f"select c3 from {self.dbname}.ct4")
|
||||||
data_ct4_c3 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c3 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c3 from t1")
|
tdSql.query(f"select c3 from {self.dbname}.t1")
|
||||||
data_t1_c3 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c3 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdSql.query("select cast(c3 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c3 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c3)):
|
for i in range(len(data_ct4_c3)):
|
||||||
tdSql.checkData( i, 0, data_ct4_c3[i])
|
tdSql.checkData( i, 0, data_ct4_c3[i])
|
||||||
tdSql.query("select cast(c3 as bigint) as b from t1")
|
tdSql.query(f"select cast(c3 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c3)):
|
for i in range(len(data_t1_c3)):
|
||||||
tdSql.checkData( i, 0, data_t1_c3[i])
|
tdSql.checkData( i, 0, data_t1_c3[i])
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step13: cast smallint to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step13: cast smallint to binary, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c3 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c3 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c3)):
|
for i in range(len(data_ct4_c3)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c3[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c3[i]) )
|
||||||
tdSql.query("select cast(c3 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c3 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c3)):
|
for i in range(len(data_t1_c3)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step14: cast smallint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step14: cast smallint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c3 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c3 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c3)):
|
for i in range(len(data_ct4_c3)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c3[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c3[i]) )
|
||||||
tdSql.query("select cast(c3 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c3 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c3)):
|
for i in range(len(data_t1_c3)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step15: cast smallint to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step15: cast smallint to timestamp, expect changes to timestamp ")
|
||||||
|
|
||||||
tdSql.query("select cast(c3 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c3 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c3)):
|
for i in range(len(data_ct4_c3)):
|
||||||
if data_ct4_c3[i] is None:
|
if data_ct4_c3[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -221,7 +222,7 @@ class TDTestCase:
|
||||||
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
tdSql.query("select cast(c3 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c3 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c3)):
|
for i in range(len(data_t1_c3)):
|
||||||
if data_ct4_c3[i] is None:
|
if data_ct4_c3[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -234,40 +235,40 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step16: cast tinyint to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step16: cast tinyint to bigint, expect no changes")
|
||||||
tdSql.query("select c4 from ct4")
|
tdSql.query(f"select c4 from {self.dbname}.ct4")
|
||||||
data_ct4_c4 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c4 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c4 from t1")
|
tdSql.query(f"select c4 from {self.dbname}.t1")
|
||||||
data_t1_c4 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c4 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdSql.query("select cast(c4 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c4 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c4)):
|
for i in range(len(data_ct4_c4)):
|
||||||
tdSql.checkData( i, 0, data_ct4_c4[i])
|
tdSql.checkData( i, 0, data_ct4_c4[i])
|
||||||
tdSql.query("select cast(c4 as bigint) as b from t1")
|
tdSql.query(f"select cast(c4 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c4)):
|
for i in range(len(data_t1_c4)):
|
||||||
tdSql.checkData( i, 0, data_t1_c4[i])
|
tdSql.checkData( i, 0, data_t1_c4[i])
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step17: cast tinyint to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step17: cast tinyint to binary, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c4 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c4 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c4)):
|
for i in range(len(data_ct4_c4)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c4[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c4[i]) )
|
||||||
tdSql.query("select cast(c4 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c4 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c4)):
|
for i in range(len(data_t1_c4)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step18: cast tinyint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step18: cast tinyint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query("select cast(c4 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c4 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c4)):
|
for i in range(len(data_ct4_c4)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c4[i]) )
|
tdSql.checkData( i, 0, str(data_ct4_c4[i]) )
|
||||||
tdSql.query("select cast(c4 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c4 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c4)):
|
for i in range(len(data_t1_c4)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step19: cast tinyint to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step19: cast tinyint to timestamp, expect changes to timestamp ")
|
||||||
|
|
||||||
tdSql.query("select cast(c4 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c4 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c4)):
|
for i in range(len(data_ct4_c4)):
|
||||||
if data_ct4_c4[i] is None:
|
if data_ct4_c4[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -278,7 +279,7 @@ class TDTestCase:
|
||||||
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
tdSql.query("select cast(c4 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c4 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c4)):
|
for i in range(len(data_t1_c4)):
|
||||||
if data_ct4_c4[i] is None:
|
if data_ct4_c4[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -291,36 +292,36 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step20: cast float to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step20: cast float to bigint, expect no changes")
|
||||||
tdSql.query("select c5 from ct4")
|
tdSql.query(f"select c5 from {self.dbname}.ct4")
|
||||||
data_ct4_c5 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c5 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c5 from t1")
|
tdSql.query(f"select c5 from {self.dbname}.t1")
|
||||||
data_t1_c5 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c5 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdSql.query("select cast(c5 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c5 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, int(data_ct4_c5[i]) )
|
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, int(data_ct4_c5[i]) )
|
||||||
tdSql.query("select cast(c5 as bigint) as b from t1")
|
tdSql.query(f"select cast(c5 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, int(data_t1_c5[i]) )
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, int(data_t1_c5[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step21: cast float to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step21: cast float to binary, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c5 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
tdSql.query("select cast(c5 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step22: cast float to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step22: cast float to nchar, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c5 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
tdSql.query("select cast(c5 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step23: cast float to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step23: cast float to timestamp, expect changes to timestamp ")
|
||||||
tdSql.query("select cast(c5 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c5 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
if data_ct4_c5[i] is None:
|
if data_ct4_c5[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -330,7 +331,7 @@ class TDTestCase:
|
||||||
date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c5[i]/1000))
|
date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c5[i]/1000))
|
||||||
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
tdSql.query("select cast(c5 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c5 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
if data_t1_c5[i] is None:
|
if data_t1_c5[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -342,15 +343,15 @@ class TDTestCase:
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step24: cast double to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step24: cast double to bigint, expect no changes")
|
||||||
tdSql.query("select c6 from ct4")
|
tdSql.query(f"select c6 from {self.dbname}.ct4")
|
||||||
data_ct4_c6 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c6 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c6 from t1")
|
tdSql.query(f"select c6 from {self.dbname}.t1")
|
||||||
data_t1_c6 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c6 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdSql.query("select cast(c6 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c6 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c6)):
|
for i in range(len(data_ct4_c6)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, int(data_ct4_c6[i]) )
|
tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, int(data_ct4_c6[i]) )
|
||||||
tdSql.query("select cast(c6 as bigint) as b from t1")
|
tdSql.query(f"select cast(c6 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c6)):
|
for i in range(len(data_t1_c6)):
|
||||||
if data_t1_c6[i] is None:
|
if data_t1_c6[i] is None:
|
||||||
tdSql.checkData( i, 0, None )
|
tdSql.checkData( i, 0, None )
|
||||||
|
@ -360,23 +361,23 @@ class TDTestCase:
|
||||||
tdSql.checkData( i, 0, int(data_t1_c6[i]) )
|
tdSql.checkData( i, 0, int(data_t1_c6[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step25: cast double to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step25: cast double to binary, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c6 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c6 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c6)):
|
for i in range(len(data_ct4_c6)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c6[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c6[i]:.6f}' )
|
||||||
tdSql.query("select cast(c6 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c6 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c6)):
|
for i in range(len(data_t1_c6)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkData( i, 0, f'{data_t1_c6[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkData( i, 0, f'{data_t1_c6[i]:.6f}' )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step26: cast double to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step26: cast double to nchar, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c6 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c6 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c6)):
|
for i in range(len(data_ct4_c6)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c6[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c6[i]:.6f}' )
|
||||||
tdSql.query("select cast(c6 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c6 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c6)):
|
for i in range(len(data_t1_c6)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkData( i, 0, f'{data_t1_c6[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkData( i, 0, f'{data_t1_c6[i]:.6f}' )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step27: cast double to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step27: cast double to timestamp, expect changes to timestamp ")
|
||||||
tdSql.query("select cast(c6 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c6 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c6)):
|
for i in range(len(data_ct4_c6)):
|
||||||
if data_ct4_c6[i] is None:
|
if data_ct4_c6[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -387,7 +388,7 @@ class TDTestCase:
|
||||||
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
tdSql.query("select cast(c6 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c6 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c6)):
|
for i in range(len(data_t1_c6)):
|
||||||
if data_t1_c6[i] is None:
|
if data_t1_c6[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -401,36 +402,36 @@ class TDTestCase:
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step28: cast bool to bigint, expect no changes")
|
tdLog.printNoPrefix("==========step28: cast bool to bigint, expect no changes")
|
||||||
tdSql.query("select c7 from ct4")
|
tdSql.query(f"select c7 from {self.dbname}.ct4")
|
||||||
data_ct4_c7 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c7 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c7 from t1")
|
tdSql.query(f"select c7 from {self.dbname}.t1")
|
||||||
data_t1_c7 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c7 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdSql.query("select cast(c7 as bigint) as b from ct4")
|
tdSql.query(f"select cast(c7 as bigint) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c7)):
|
for i in range(len(data_ct4_c7)):
|
||||||
tdSql.checkData( i, 0, data_ct4_c7[i])
|
tdSql.checkData( i, 0, data_ct4_c7[i])
|
||||||
tdSql.query("select cast(c7 as bigint) as b from t1")
|
tdSql.query(f"select cast(c7 as bigint) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c7)):
|
for i in range(len(data_t1_c7)):
|
||||||
tdSql.checkData( i, 0, data_t1_c7[i])
|
tdSql.checkData( i, 0, data_t1_c7[i])
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step29: cast bool to binary, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step29: cast bool to binary, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c7 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c7 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c7)):
|
for i in range(len(data_ct4_c7)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c7[i] is None else tdSql.checkData( i, 0, str(data_ct4_c7[i]).lower() )
|
tdSql.checkData( i, 0, None ) if data_ct4_c7[i] is None else tdSql.checkData( i, 0, str(data_ct4_c7[i]).lower() )
|
||||||
tdSql.query("select cast(c7 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c7 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c7)):
|
for i in range(len(data_t1_c7)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c7[i] is None else tdSql.checkData( i, 0, str(data_t1_c7[i]).lower() )
|
tdSql.checkData( i, 0, None ) if data_t1_c7[i] is None else tdSql.checkData( i, 0, str(data_t1_c7[i]).lower() )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step30: cast bool to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step30: cast bool to nchar, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c7 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c7 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c7)):
|
for i in range(len(data_ct4_c7)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c7[i] is None else tdSql.checkData( i, 0, str(data_ct4_c7[i]).lower() )
|
tdSql.checkData( i, 0, None ) if data_ct4_c7[i] is None else tdSql.checkData( i, 0, str(data_ct4_c7[i]).lower() )
|
||||||
tdSql.query("select cast(c7 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c7 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c7)):
|
for i in range(len(data_t1_c7)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c7[i] is None else tdSql.checkData( i, 0, str(data_t1_c7[i]).lower() )
|
tdSql.checkData( i, 0, None ) if data_t1_c7[i] is None else tdSql.checkData( i, 0, str(data_t1_c7[i]).lower() )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step31: cast bool to timestamp, expect changes to timestamp ")
|
tdLog.printNoPrefix("==========step31: cast bool to timestamp, expect changes to timestamp ")
|
||||||
tdSql.query("select cast(c7 as timestamp) as b from ct4")
|
tdSql.query(f"select cast(c7 as timestamp) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c7)):
|
for i in range(len(data_ct4_c7)):
|
||||||
if data_ct4_c7[i] is None:
|
if data_ct4_c7[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -440,7 +441,7 @@ class TDTestCase:
|
||||||
date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c7[i]/1000))
|
date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c7[i]/1000))
|
||||||
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
tdSql.query("select cast(c7 as timestamp) as b from t1")
|
tdSql.query(f"select cast(c7 as timestamp) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c7)):
|
for i in range(len(data_t1_c7)):
|
||||||
if data_t1_c7[i] is None:
|
if data_t1_c7[i] is None:
|
||||||
tdSql.checkData( i, 0 , None )
|
tdSql.checkData( i, 0 , None )
|
||||||
|
@ -452,22 +453,22 @@ class TDTestCase:
|
||||||
tdSql.checkData( i, 0, date_data)
|
tdSql.checkData( i, 0, date_data)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select c8 from ct4")
|
tdSql.query(f"select c8 from {self.dbname}.ct4")
|
||||||
data_ct4_c8 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c8 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c8 from t1")
|
tdSql.query(f"select c8 from {self.dbname}.t1")
|
||||||
data_t1_c8 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c8 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step32: cast binary to binary, expect no changes ")
|
tdLog.printNoPrefix("==========step32: cast binary to binary, expect no changes ")
|
||||||
tdSql.query("select cast(c8 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c8 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c8)):
|
for i in range(len(data_ct4_c8)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c8[i] is None else tdSql.checkData(i,0,data_ct4_c8[i])
|
tdSql.checkData( i, 0, None ) if data_ct4_c8[i] is None else tdSql.checkData(i,0,data_ct4_c8[i])
|
||||||
|
|
||||||
tdSql.query("select cast(c8 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c8 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c8)):
|
for i in range(len(data_t1_c8)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c8[i] is None else tdSql.checkData(i,0,data_t1_c8[i])
|
tdSql.checkData( i, 0, None ) if data_t1_c8[i] is None else tdSql.checkData(i,0,data_t1_c8[i])
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step33: cast binary to binary, expect truncate ")
|
tdLog.printNoPrefix("==========step33: cast binary to binary, expect truncate ")
|
||||||
tdSql.query("select cast(c8 as binary(2)) as b from ct4")
|
tdSql.query(f"select cast(c8 as binary(2)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c8)):
|
for i in range(len(data_ct4_c8)):
|
||||||
if data_ct4_c8[i] is None:
|
if data_ct4_c8[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -476,7 +477,7 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c8[i][:2]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c8[i][:2]}")
|
||||||
tdSql.query("select cast(c8 as binary(2)) as b from t1")
|
tdSql.query(f"select cast(c8 as binary(2)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c8)):
|
for i in range(len(data_t1_c8)):
|
||||||
if data_t1_c8[i] is None:
|
if data_t1_c8[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -487,7 +488,7 @@ class TDTestCase:
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c8[i][:2]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c8[i][:2]}")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step34: cast binary to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step34: cast binary to nchar, expect changes to str(int) ")
|
||||||
tdSql.query("select cast(c8 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c8 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c8)):
|
for i in range(len(data_ct4_c8)):
|
||||||
if data_ct4_c8[i] is None:
|
if data_ct4_c8[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -496,7 +497,7 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c8[i]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c8[i]}")
|
||||||
tdSql.query("select cast(c8 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c8 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c8)):
|
for i in range(len(data_t1_c8)):
|
||||||
if data_t1_c8[i] is None:
|
if data_t1_c8[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -507,14 +508,14 @@ class TDTestCase:
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c8[i]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c8[i]}")
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select c9 from ct4")
|
tdSql.query(f"select c9 from {self.dbname}.ct4")
|
||||||
data_ct4_c9 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c9 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c9 from t1")
|
tdSql.query(f"select c9 from {self.dbname}.t1")
|
||||||
data_t1_c9 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c9 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
"c10 timestamp"
|
"c10 timestamp"
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step35: cast nchar to nchar, expect no changes ")
|
tdLog.printNoPrefix("==========step35: cast nchar to nchar, expect no changes ")
|
||||||
tdSql.query("select cast(c9 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c9 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c9)):
|
for i in range(len(data_ct4_c9)):
|
||||||
if data_ct4_c9[i] is None:
|
if data_ct4_c9[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -523,7 +524,7 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c9[i]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c9[i]}")
|
||||||
tdSql.query("select cast(c9 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c9 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c9)):
|
for i in range(len(data_t1_c9)):
|
||||||
tdSql.checkData( i, 0, data_t1_c9[i] )
|
tdSql.checkData( i, 0, data_t1_c9[i] )
|
||||||
if data_t1_c9[i] is None:
|
if data_t1_c9[i] is None:
|
||||||
|
@ -535,7 +536,7 @@ class TDTestCase:
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c9[i]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c9[i]}")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step36: cast nchar to nchar, expect truncate ")
|
tdLog.printNoPrefix("==========step36: cast nchar to nchar, expect truncate ")
|
||||||
tdSql.query("select cast(c9 as nchar(2)) as b from ct4")
|
tdSql.query(f"select cast(c9 as nchar(2)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c9)):
|
for i in range(len(data_ct4_c9)):
|
||||||
if data_ct4_c9[i] is None:
|
if data_ct4_c9[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -544,7 +545,7 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c9[i][:2]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_ct4_c9[i][:2]}")
|
||||||
tdSql.query("select cast(c9 as nchar(2)) as b from t1")
|
tdSql.query(f"select cast(c9 as nchar(2)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c9)):
|
for i in range(len(data_t1_c9)):
|
||||||
if data_t1_c9[i] is None:
|
if data_t1_c9[i] is None:
|
||||||
tdSql.checkData( i, 0, None)
|
tdSql.checkData( i, 0, None)
|
||||||
|
@ -554,141 +555,144 @@ class TDTestCase:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c9[i][:2]}")
|
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{tdSql.sql} row:{i} col:0 data:{tdSql.queryResult[i][0]} != expect:{data_t1_c9[i][:2]}")
|
||||||
|
|
||||||
tdSql.query("select c10 from ct4")
|
tdSql.query(f"select c10 from {self.dbname}.ct4")
|
||||||
data_ct4_c10 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_ct4_c10 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
tdSql.query("select c10 from t1")
|
tdSql.query(f"select c10 from {self.dbname}.t1")
|
||||||
data_t1_c10 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
data_t1_c10 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)]
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step37: cast timestamp to nchar, expect no changes ")
|
tdLog.printNoPrefix("==========step37: cast timestamp to nchar, expect no changes ")
|
||||||
tdSql.query("select cast(c10 as nchar(32)) as b from ct4")
|
tdSql.query(f"select cast(c10 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c10)):
|
for i in range(len(data_ct4_c10)):
|
||||||
if data_ct4_c10[i] is None:
|
if data_ct4_c10[i] is None:
|
||||||
tdSql.checkData( i, 0, None )
|
tdSql.checkData( i, 0, None )
|
||||||
else:
|
else:
|
||||||
time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
# time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
||||||
|
time2str = str(int((datetime.datetime.timestamp(data_ct4_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
|
||||||
tdSql.checkData( i, 0, time2str )
|
tdSql.checkData( i, 0, time2str )
|
||||||
tdSql.query("select cast(c10 as nchar(32)) as b from t1")
|
tdSql.query(f"select cast(c10 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c10)):
|
for i in range(len(data_t1_c10)):
|
||||||
if data_t1_c10[i] is None:
|
if data_t1_c10[i] is None:
|
||||||
tdSql.checkData( i, 0, None )
|
tdSql.checkData( i, 0, None )
|
||||||
elif i == 10:
|
elif i == 10:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
# time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
||||||
|
time2str = str(int((datetime.datetime.timestamp(data_t1_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
|
||||||
tdSql.checkData( i, 0, time2str )
|
tdSql.checkData( i, 0, time2str )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step38: cast timestamp to binary, expect no changes ")
|
tdLog.printNoPrefix("==========step38: cast timestamp to binary, expect no changes ")
|
||||||
tdSql.query("select cast(c10 as binary(32)) as b from ct4")
|
tdSql.query(f"select cast(c10 as binary(32)) as b from {self.dbname}.ct4")
|
||||||
for i in range(len(data_ct4_c10)):
|
for i in range(len(data_ct4_c10)):
|
||||||
if data_ct4_c10[i] is None:
|
if data_ct4_c10[i] is None:
|
||||||
tdSql.checkData( i, 0, None )
|
tdSql.checkData( i, 0, None )
|
||||||
else:
|
else:
|
||||||
time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
# time2str = str(int((data_ct4_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
||||||
|
time2str = str(int((datetime.datetime.timestamp(data_ct4_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
|
||||||
tdSql.checkData( i, 0, time2str )
|
tdSql.checkData( i, 0, time2str )
|
||||||
tdSql.query("select cast(c10 as binary(32)) as b from t1")
|
tdSql.query(f"select cast(c10 as binary(32)) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c10)):
|
for i in range(len(data_t1_c10)):
|
||||||
if data_t1_c10[i] is None:
|
if data_t1_c10[i] is None:
|
||||||
tdSql.checkData( i, 0, None )
|
tdSql.checkData( i, 0, None )
|
||||||
elif i == 10:
|
elif i == 10:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
# time2str = str(int((data_t1_c10[i]-datetime.datetime.fromtimestamp(0)).total_seconds()*1000))
|
||||||
|
time2str = str(int((datetime.datetime.timestamp(data_t1_c10[i])-datetime.datetime.timestamp(datetime.datetime.fromtimestamp(0)))*1000))
|
||||||
tdSql.checkData( i, 0, time2str )
|
tdSql.checkData( i, 0, time2str )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ")
|
tdLog.printNoPrefix("==========step39: cast constant operation to bigint, expect change to int ")
|
||||||
tdSql.query("select cast(12121.23323131 as bigint) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 as bigint) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, 12121) for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, 12121) for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as binary(16)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 as binary(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as binary(2)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 as binary(2)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as nchar(16)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 as nchar(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 as nchar(2)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 as nchar(2)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
|
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as bigint) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 321.876897998 as bigint) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, 12443) for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, 12443) for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as binary(16)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 321.876897998 as binary(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12443.110129') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12443.110129') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as binary(3)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 321.876897998 as binary(3)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '124') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '124') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as nchar(16)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 321.876897998 as nchar(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12443.110129') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12443.110129') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 321.876897998 as nchar(3)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 321.876897998 as nchar(3)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '124') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '124') for i in range(tdSql.queryRows) )
|
||||||
|
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as bigint) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as bigint) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, 12121) for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, 12121) for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as binary(16)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as binary(2)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary(2)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as nchar(16)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query("select cast(12121.23323131 + 'test~!@`#$%^&*()}{][;><.,' as nchar(2)) as b from ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(2)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step40: error cast condition, should return error ")
|
tdLog.printNoPrefix("==========step40: current cast condition, should return ok ")
|
||||||
#tdSql.error("select cast(c1 as int) as b from ct4")
|
tdSql.query(f"select cast(c1 as int) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as bool) as b from ct4")
|
tdSql.query(f"select cast(c1 as bool) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as tinyint) as b from ct4")
|
tdSql.query(f"select cast(c1 as tinyint) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as smallint) as b from ct4")
|
tdSql.query(f"select cast(c1 as smallint) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as float) as b from ct4")
|
tdSql.query(f"select cast(c1 as float) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as double) as b from ct4")
|
tdSql.query(f"select cast(c1 as double) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as tinyint unsigned) as b from ct4")
|
tdSql.query(f"select cast(c1 as tinyint unsigned) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as smallint unsigned) as b from ct4")
|
tdSql.query(f"select cast(c1 as smallint unsigned) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c1 as int unsigned) as b from ct4")
|
tdSql.query(f"select cast(c1 as int unsigned) as b from {self.dbname}.ct4")
|
||||||
|
|
||||||
#tdSql.error("select cast(c2 as int) as b from ct4")
|
tdSql.query(f"select cast(c2 as int) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c3 as bool) as b from ct4")
|
tdSql.query(f"select cast(c3 as bool) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c4 as tinyint) as b from ct4")
|
tdSql.query(f"select cast(c4 as tinyint) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c5 as smallint) as b from ct4")
|
tdSql.query(f"select cast(c5 as smallint) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c6 as float) as b from ct4")
|
tdSql.query(f"select cast(c6 as float) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c7 as double) as b from ct4")
|
tdSql.query(f"select cast(c7 as double) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c8 as tinyint unsigned) as b from ct4")
|
tdSql.query(f"select cast(c8 as tinyint unsigned) as b from {self.dbname}.ct4")
|
||||||
|
|
||||||
#tdSql.error("select cast(c8 as timestamp ) as b from ct4")
|
tdSql.query(f"select cast(c8 as timestamp ) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c9 as timestamp ) as b from ct4")
|
tdSql.query(f"select cast(c9 as timestamp ) as b from {self.dbname}.ct4")
|
||||||
#tdSql.error("select cast(c9 as binary(64) ) as b from ct4")
|
tdSql.query(f"select cast(c9 as binary(64) ) as b from {self.dbname}.ct4")
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {self.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)
|
(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)
|
tags (t1 int)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''
|
f'''
|
||||||
create table t1
|
create table {self.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)
|
(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):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table {self.dbname}.ct{i+1} using {self.dbname}.stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
tdLog.printNoPrefix("==========step2:insert data")
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
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 {self.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(
|
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 {self.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(f"insert into {self.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 )")
|
tdSql.execute(f"insert into {self.dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -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(f"insert into {self.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 ) ")
|
tdSql.execute(f"insert into {self.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 ) ")
|
tdSql.execute(f"insert into {self.dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into t1 values
|
f'''insert into {self.dbname}.t1 values
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( '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-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 )
|
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||||
|
@ -706,10 +710,10 @@ class TDTestCase:
|
||||||
|
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
# tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
# tdDnodes.start(1)
|
||||||
|
|
||||||
tdSql.execute("use db")
|
tdSql.execute(f"flush database {self.dbname}")
|
||||||
|
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,21 @@ python3 ./test.py -f 2-query/apercentile.py
|
||||||
python3 ./test.py -f 2-query/apercentile.py -R
|
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
|
||||||
python3 ./test.py -f 2-query/arccos.py -R
|
python3 ./test.py -f 2-query/arccos.py -R
|
||||||
|
python3 ./test.py -f 2-query/arcsin.py
|
||||||
|
python3 ./test.py -f 2-query/arcsin.py -R
|
||||||
|
python3 ./test.py -f 2-query/arctan.py
|
||||||
|
python3 ./test.py -f 2-query/arctan.py -R
|
||||||
|
python3 ./test.py -f 2-query/avg.py
|
||||||
|
python3 ./test.py -f 2-query/avg.py -R
|
||||||
python3 ./test.py -f 2-query/between.py
|
python3 ./test.py -f 2-query/between.py
|
||||||
|
python3 ./test.py -f 2-query/between.py -R
|
||||||
|
python3 ./test.py -f 2-query/bottom.py
|
||||||
|
python3 ./test.py -f 2-query/bottom.py -R
|
||||||
|
python3 ./test.py -f 2-query/cast.py
|
||||||
|
python3 ./test.py -f 2-query/cast.py -R
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/distinct.py
|
python3 ./test.py -f 2-query/distinct.py
|
||||||
python3 ./test.py -f 2-query/varchar.py
|
python3 ./test.py -f 2-query/varchar.py
|
||||||
python3 ./test.py -f 2-query/ltrim.py
|
python3 ./test.py -f 2-query/ltrim.py
|
||||||
|
@ -51,7 +62,6 @@ python3 ./test.py -f 2-query/upper.py
|
||||||
python3 ./test.py -f 2-query/lower.py
|
python3 ./test.py -f 2-query/lower.py
|
||||||
python3 ./test.py -f 2-query/join.py
|
python3 ./test.py -f 2-query/join.py
|
||||||
python3 ./test.py -f 2-query/join2.py
|
python3 ./test.py -f 2-query/join2.py
|
||||||
python3 ./test.py -f 2-query/cast.py
|
|
||||||
python3 ./test.py -f 2-query/substr.py
|
python3 ./test.py -f 2-query/substr.py
|
||||||
python3 ./test.py -f 2-query/union.py
|
python3 ./test.py -f 2-query/union.py
|
||||||
python3 ./test.py -f 2-query/union1.py
|
python3 ./test.py -f 2-query/union1.py
|
||||||
|
@ -83,7 +93,6 @@ python3 ./test.py -f 2-query/Timediff.py
|
||||||
python3 ./test.py -f 2-query/json_tag.py
|
python3 ./test.py -f 2-query/json_tag.py
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/top.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/percentile.py
|
||||||
python3 ./test.py -f 2-query/ceil.py
|
python3 ./test.py -f 2-query/ceil.py
|
||||||
python3 ./test.py -f 2-query/floor.py
|
python3 ./test.py -f 2-query/floor.py
|
||||||
|
@ -94,15 +103,12 @@ python3 ./test.py -f 2-query/sqrt.py
|
||||||
python3 ./test.py -f 2-query/sin.py
|
python3 ./test.py -f 2-query/sin.py
|
||||||
python3 ./test.py -f 2-query/cos.py
|
python3 ./test.py -f 2-query/cos.py
|
||||||
python3 ./test.py -f 2-query/tan.py
|
python3 ./test.py -f 2-query/tan.py
|
||||||
python3 ./test.py -f 2-query/arcsin.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/query_cols_tags_and_or.py
|
||||||
# python3 ./test.py -f 2-query/nestedQuery.py
|
# python3 ./test.py -f 2-query/nestedQuery.py
|
||||||
# TD-15983 subquery output duplicate name column.
|
# TD-15983 subquery output duplicate name column.
|
||||||
# Please Xiangyang Guo modify the following script
|
# Please Xiangyang Guo modify the following script
|
||||||
# python3 ./test.py -f 2-query/nestedQuery_str.py
|
# python3 ./test.py -f 2-query/nestedQuery_str.py
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/avg.py
|
|
||||||
python3 ./test.py -f 2-query/elapsed.py
|
python3 ./test.py -f 2-query/elapsed.py
|
||||||
python3 ./test.py -f 2-query/csum.py
|
python3 ./test.py -f 2-query/csum.py
|
||||||
python3 ./test.py -f 2-query/mavg.py
|
python3 ./test.py -f 2-query/mavg.py
|
||||||
|
|
Loading…
Reference in New Issue