未验证 提交 13ecf18c 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #16247 from taosdata/cpwu/3.0

Test: fix case to support rest API
...@@ -199,22 +199,22 @@ class TDCom: ...@@ -199,22 +199,22 @@ class TDCom:
res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0]) res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0])
return res return res
def cleanTb(self, type="taosc"): def cleanTb(self, type="taosc", dbname="db"):
''' '''
type is taosc or restful type is taosc or restful
''' '''
query_sql = "show stables" query_sql = f"show {dbname}.stables"
res_row_list = tdSql.query(query_sql, True) res_row_list = tdSql.query(query_sql, True)
stb_list = map(lambda x: x[0], res_row_list) stb_list = map(lambda x: x[0], res_row_list)
for stb in stb_list: for stb in stb_list:
if type == "taosc": if type == "taosc":
tdSql.execute(f'drop table if exists `{stb}`') tdSql.execute(f'drop table if exists {dbname}.`{stb}`')
if not stb[0].isdigit(): if not stb[0].isdigit():
tdSql.execute(f'drop table if exists {stb}') tdSql.execute(f'drop table if exists {dbname}.{stb}')
elif type == "restful": elif type == "restful":
self.restApiPost(f"drop table if exists `{stb}`") self.restApiPost(f"drop table if exists {dbname}.`{stb}`")
if not stb[0].isdigit(): if not stb[0].isdigit():
self.restApiPost(f"drop table if exists {stb}") self.restApiPost(f"drop table if exists {dbname}.{stb}")
def dateToTs(self, datetime_input): def dateToTs(self, datetime_input):
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
......
...@@ -36,9 +36,9 @@ class TDSimClient: ...@@ -36,9 +36,9 @@ class TDSimClient:
"rpcDebugFlag": "143", "rpcDebugFlag": "143",
"tmrDebugFlag": "131", "tmrDebugFlag": "131",
"cDebugFlag": "143", "cDebugFlag": "143",
"udebugFlag": "143", "uDebugFlag": "143",
"jnidebugFlag": "143", "jniDebugFlag": "143",
"qdebugFlag": "143", "qDebugFlag": "143",
"supportVnodes": "1024", "supportVnodes": "1024",
"telemetryReporting": "0", "telemetryReporting": "0",
} }
...@@ -134,7 +134,6 @@ class TDDnode: ...@@ -134,7 +134,6 @@ class TDDnode:
"uDebugFlag": "131", "uDebugFlag": "131",
"sDebugFlag": "143", "sDebugFlag": "143",
"wDebugFlag": "143", "wDebugFlag": "143",
"qdebugFlag": "143",
"numOfLogLines": "100000000", "numOfLogLines": "100000000",
"statusInterval": "1", "statusInterval": "1",
"supportVnodes": "1024", "supportVnodes": "1024",
...@@ -484,7 +483,7 @@ class TDDnode: ...@@ -484,7 +483,7 @@ class TDDnode:
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output( processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8") psCmd, shell=True).decode("utf-8")
onlyKillOnceWindows = 0 onlyKillOnceWindows = 0
while(processID): while(processID):
if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'): if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'):
......
...@@ -102,7 +102,7 @@ class TDSql: ...@@ -102,7 +102,7 @@ class TDSql:
caller = inspect.getframeinfo(inspect.stack()[1][0]) caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, sql, repr(e)) args = (caller.filename, caller.lineno, sql, repr(e))
tdLog.notice("%s(%d) failed: sql:%s, %s" % args) tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
raise Exception(repr(e)) raise Exception(repr(e))
i+=1 i+=1
time.sleep(1) time.sleep(1)
pass pass
...@@ -225,25 +225,21 @@ class TDSql: ...@@ -225,25 +225,21 @@ class TDSql:
# suppose user want to check nanosecond timestamp if a longer data passed # suppose user want to check nanosecond timestamp if a longer data passed
if (len(data) >= 28): if (len(data) >= 28):
if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data):
tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
(self.sql, row, col, self.queryResult[row][col], data))
else: else:
if self.queryResult[row][col] == _parse_datetime(data): if self.queryResult[row][col] == _parse_datetime(data):
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
(self.sql, row, col, self.queryResult[row][col], data))
return return
if str(self.queryResult[row][col]) == str(data): if str(self.queryResult[row][col]) == str(data):
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
(self.sql, row, col, self.queryResult[row][col], data))
return return
elif isinstance(data, float): elif isinstance(data, float):
if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001: if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001:
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
(self.sql, row, col, self.queryResult[row][col], data))
elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001: elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001:
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
(self.sql, row, col, self.queryResult[row][col], data))
else: else:
caller = inspect.getframeinfo(inspect.stack()[1][0]) caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
...@@ -254,21 +250,7 @@ class TDSql: ...@@ -254,21 +250,7 @@ class TDSql:
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args)
if data is None: tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
(self.sql, row, col, self.queryResult[row][col], data))
elif isinstance(data, str):
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
(self.sql, row, col, self.queryResult[row][col], data))
elif isinstance(data, datetime.date):
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
(self.sql, row, col, self.queryResult[row][col], data))
elif isinstance(data, float):
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
(self.sql, row, col, self.queryResult[row][col], data))
else:
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" %
(self.sql, row, col, self.queryResult[row][col], data))
def getData(self, row, col): def getData(self, row, col):
self.checkRowCol(row, col) self.checkRowCol(row, col)
...@@ -307,7 +289,7 @@ class TDSql: ...@@ -307,7 +289,7 @@ class TDSql:
caller = inspect.getframeinfo(inspect.stack()[1][0]) caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, sql, repr(e)) args = (caller.filename, caller.lineno, sql, repr(e))
tdLog.notice("%s(%d) failed: sql:%s, %s" % args) tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
raise Exception(repr(e)) raise Exception(repr(e))
i+=1 i+=1
time.sleep(1) time.sleep(1)
pass pass
...@@ -329,7 +311,7 @@ class TDSql: ...@@ -329,7 +311,7 @@ class TDSql:
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): def __check_equal(self, elm, expect_elm):
if not type(elm) in(list, tuple) and elm == expect_elm: if elm == expect_elm:
return True return True
if type(elm) in(list, tuple) and type(expect_elm) in(list, tuple): if type(elm) in(list, tuple) and type(expect_elm) in(list, tuple):
if len(elm) != len(expect_elm): if len(elm) != len(expect_elm):
......
...@@ -31,7 +31,7 @@ if platform.system().lower() == 'windows': ...@@ -31,7 +31,7 @@ if platform.system().lower() == 'windows':
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), False)
self._conn = conn self._conn = conn
def createDb(self, name="test", db_update_tag=0): def createDb(self, name="test", db_update_tag=0):
...@@ -357,7 +357,7 @@ class TDTestCase: ...@@ -357,7 +357,7 @@ class TDTestCase:
""" """
normal tags and cols, one for every elm normal tags and cols, one for every elm
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -365,7 +365,7 @@ class TDTestCase: ...@@ -365,7 +365,7 @@ class TDTestCase:
""" """
check all normal type check all normal type
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"] full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"]
for t_type in full_type_list: for t_type in full_type_list:
input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type) input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type)
...@@ -379,7 +379,7 @@ class TDTestCase: ...@@ -379,7 +379,7 @@ class TDTestCase:
please test : please test :
binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"' binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"'
''' '''
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"'
nchar_symbols = f'L{binary_symbols}' nchar_symbols = f'L{binary_symbols}'
input_sql, stb_name = self.genFullTypeSql(c7=binary_symbols, c8=nchar_symbols, t7=binary_symbols, t8=nchar_symbols) input_sql, stb_name = self.genFullTypeSql(c7=binary_symbols, c8=nchar_symbols, t7=binary_symbols, t8=nchar_symbols)
...@@ -390,7 +390,7 @@ class TDTestCase: ...@@ -390,7 +390,7 @@ class TDTestCase:
test ts list --> ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"] test ts list --> ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"]
# ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过 # ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
ts_list = ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022", 0] ts_list = ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022", 0]
for ts in ts_list: for ts in ts_list:
input_sql, stb_name = self.genFullTypeSql(ts=ts) input_sql, stb_name = self.genFullTypeSql(ts=ts)
...@@ -401,7 +401,7 @@ class TDTestCase: ...@@ -401,7 +401,7 @@ class TDTestCase:
check id.index in tags check id.index in tags
eg: t0=**,id=**,t1=** eg: t0=**,id=**,t1=**
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) input_sql, stb_name = self.genFullTypeSql(id_change_tag=True)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -410,7 +410,7 @@ class TDTestCase: ...@@ -410,7 +410,7 @@ class TDTestCase:
check id param check id param
eg: id and ID eg: id and ID
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True) input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True) input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True)
...@@ -420,7 +420,7 @@ class TDTestCase: ...@@ -420,7 +420,7 @@ class TDTestCase:
""" """
id not exist id not exist
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True) input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
query_sql = f"select tbname from {stb_name}" query_sql = f"select tbname from {stb_name}"
...@@ -436,10 +436,10 @@ class TDTestCase: ...@@ -436,10 +436,10 @@ class TDTestCase:
max col count is ?? max col count is ??
""" """
for input_sql in [self.genLongSql(127, 1)[0], self.genLongSql(1, 4093)[0]]: for input_sql in [self.genLongSql(127, 1)[0], self.genLongSql(1, 4093)[0]]:
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
for input_sql in [self.genLongSql(129, 1)[0], self.genLongSql(1, 4095)[0]]: for input_sql in [self.genLongSql(129, 1)[0], self.genLongSql(1, 4095)[0]]:
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
except SchemalessError as err: except SchemalessError as err:
...@@ -450,7 +450,7 @@ class TDTestCase: ...@@ -450,7 +450,7 @@ class TDTestCase:
test illegal id name test illegal id name
mix "~!@#$¥%^&*()-+|[]、「」【】;:《》<>?" mix "~!@#$¥%^&*()-+|[]、「」【】;:《》<>?"
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
rstr = list("~!@#$¥%^&*()-+|[]、「」【】;:《》<>?") rstr = list("~!@#$¥%^&*()-+|[]、「」【】;:《》<>?")
for i in rstr: for i in rstr:
stb_name=f"aaa{i}bbb" stb_name=f"aaa{i}bbb"
...@@ -462,7 +462,7 @@ class TDTestCase: ...@@ -462,7 +462,7 @@ class TDTestCase:
""" """
id is start with num id is start with num
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql = self.genFullTypeSql(tb_name=f"\"1aaabbb\"")[0] input_sql = self.genFullTypeSql(tb_name=f"\"1aaabbb\"")[0]
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -473,7 +473,7 @@ class TDTestCase: ...@@ -473,7 +473,7 @@ class TDTestCase:
""" """
check now unsupported check now unsupported
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql = self.genFullTypeSql(ts="now")[0] input_sql = self.genFullTypeSql(ts="now")[0]
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -484,7 +484,7 @@ class TDTestCase: ...@@ -484,7 +484,7 @@ class TDTestCase:
""" """
check date format ts unsupported check date format ts unsupported
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0] input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0]
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -495,7 +495,7 @@ class TDTestCase: ...@@ -495,7 +495,7 @@ class TDTestCase:
""" """
check ts format like 16260068336390us19 check ts format like 16260068336390us19
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql = self.genFullTypeSql(ts="16260068336390us19")[0] input_sql = self.genFullTypeSql(ts="16260068336390us19")[0]
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -506,7 +506,7 @@ class TDTestCase: ...@@ -506,7 +506,7 @@ class TDTestCase:
""" """
check full type tag value limit check full type tag value limit
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
# i8 # i8
for t1 in ["-128i8", "127i8"]: for t1 in ["-128i8", "127i8"]:
input_sql, stb_name = self.genFullTypeSql(t1=t1) input_sql, stb_name = self.genFullTypeSql(t1=t1)
...@@ -602,7 +602,7 @@ class TDTestCase: ...@@ -602,7 +602,7 @@ class TDTestCase:
""" """
check full type col value limit check full type col value limit
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
# i8 # i8
for c1 in ["-128i8", "127i8"]: for c1 in ["-128i8", "127i8"]:
input_sql, stb_name = self.genFullTypeSql(c1=c1) input_sql, stb_name = self.genFullTypeSql(c1=c1)
...@@ -699,7 +699,7 @@ class TDTestCase: ...@@ -699,7 +699,7 @@ class TDTestCase:
""" """
test illegal tag col value test illegal tag col value
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
# bool # bool
for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]: for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]:
input_sql1 = self.genFullTypeSql(t0=i)[0] input_sql1 = self.genFullTypeSql(t0=i)[0]
...@@ -758,7 +758,7 @@ class TDTestCase: ...@@ -758,7 +758,7 @@ class TDTestCase:
""" """
check duplicate Id Tag Col check duplicate Id Tag Col
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql_id = self.genFullTypeSql(id_double_tag=True)[0] input_sql_id = self.genFullTypeSql(id_double_tag=True)[0]
try: try:
self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -792,7 +792,7 @@ class TDTestCase: ...@@ -792,7 +792,7 @@ class TDTestCase:
""" """
case no id when stb exist case no id when stb exist
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", c0="f") input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", c0="f")
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", c0="f") input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", c0="f")
...@@ -805,7 +805,7 @@ class TDTestCase: ...@@ -805,7 +805,7 @@ class TDTestCase:
""" """
check duplicate insert when stb exist check duplicate insert when stb exist
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -816,7 +816,7 @@ class TDTestCase: ...@@ -816,7 +816,7 @@ class TDTestCase:
""" """
check length increase check length increase
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
tb_name = tdCom.getLongName(5, "letters") tb_name = tdCom.getLongName(5, "letters")
...@@ -833,7 +833,7 @@ class TDTestCase: ...@@ -833,7 +833,7 @@ class TDTestCase:
* col is added without value when update==0 * col is added without value when update==0
* col is added with value when update==1 * col is added with value when update==1
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
for db_update_tag in [0, 1]: for db_update_tag in [0, 1]:
if db_update_tag == 1 : if db_update_tag == 1 :
...@@ -850,7 +850,7 @@ class TDTestCase: ...@@ -850,7 +850,7 @@ class TDTestCase:
""" """
check column and tag count add check column and tag count add
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f")
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -866,7 +866,7 @@ class TDTestCase: ...@@ -866,7 +866,7 @@ class TDTestCase:
condition: stb not change condition: stb not change
insert two table, keep tag unchange, change col insert two table, keep tag unchange, change col
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql(t0="f", c0="f", id_noexist_tag=True) input_sql, stb_name = self.genFullTypeSql(t0="f", c0="f", id_noexist_tag=True)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
tb_name1 = self.getNoIdTbName(stb_name) tb_name1 = self.getNoIdTbName(stb_name)
...@@ -888,7 +888,7 @@ class TDTestCase: ...@@ -888,7 +888,7 @@ class TDTestCase:
""" """
every binary and nchar must be length+2 every binary and nchar must be length+2
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
stb_name = tdCom.getLongName(7, "letters") stb_name = tdCom.getLongName(7, "letters")
tb_name = f'{stb_name}_1' tb_name = f'{stb_name}_1'
input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000' input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000'
...@@ -928,7 +928,7 @@ class TDTestCase: ...@@ -928,7 +928,7 @@ class TDTestCase:
""" """
check nchar length limit check nchar length limit
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
stb_name = tdCom.getLongName(7, "letters") stb_name = tdCom.getLongName(7, "letters")
tb_name = f'{stb_name}_1' tb_name = f'{stb_name}_1'
input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000' input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000'
...@@ -963,7 +963,7 @@ class TDTestCase: ...@@ -963,7 +963,7 @@ class TDTestCase:
""" """
test batch insert test batch insert
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
stb_name = tdCom.getLongName(8, "letters") stb_name = tdCom.getLongName(8, "letters")
# tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') # tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
...@@ -982,7 +982,7 @@ class TDTestCase: ...@@ -982,7 +982,7 @@ class TDTestCase:
""" """
test multi insert test multi insert
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
sql_list = [] sql_list = []
stb_name = tdCom.getLongName(8, "letters") stb_name = tdCom.getLongName(8, "letters")
# tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') # tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
...@@ -996,7 +996,7 @@ class TDTestCase: ...@@ -996,7 +996,7 @@ class TDTestCase:
""" """
test batch error insert test batch error insert
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
stb_name = tdCom.getLongName(8, "letters") stb_name = tdCom.getLongName(8, "letters")
lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
f"{stb_name},t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"] f"{stb_name},t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"]
...@@ -1068,7 +1068,7 @@ class TDTestCase: ...@@ -1068,7 +1068,7 @@ class TDTestCase:
""" """
thread input different stb thread input different stb
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql = self.genSqlList()[0] input_sql = self.genSqlList()[0]
self.multiThreadRun(self.genMultiThreadSeq(input_sql)) self.multiThreadRun(self.genMultiThreadSeq(input_sql))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
...@@ -1078,7 +1078,7 @@ class TDTestCase: ...@@ -1078,7 +1078,7 @@ class TDTestCase:
""" """
thread input same stb tb, different data, result keep first data thread input same stb tb, different data, result keep first data
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -1095,7 +1095,7 @@ class TDTestCase: ...@@ -1095,7 +1095,7 @@ class TDTestCase:
""" """
thread input same stb tb, different data, add columes and tags, result keep first data thread input same stb tb, different data, add columes and tags, result keep first data
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -1112,7 +1112,7 @@ class TDTestCase: ...@@ -1112,7 +1112,7 @@ class TDTestCase:
""" """
thread input same stb tb, different data, minus columes and tags, result keep first data thread input same stb tb, different data, minus columes and tags, result keep first data
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -1129,7 +1129,7 @@ class TDTestCase: ...@@ -1129,7 +1129,7 @@ class TDTestCase:
""" """
thread input same stb, different tb, different data thread input same stb, different tb, different data
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4] s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4]
...@@ -1144,7 +1144,7 @@ class TDTestCase: ...@@ -1144,7 +1144,7 @@ class TDTestCase:
""" """
thread input same stb, different tb, different data, add col, mul tag thread input same stb, different tb, different data, add col, mul tag
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
s_stb_d_tb_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[5] s_stb_d_tb_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[5]
...@@ -1159,7 +1159,7 @@ class TDTestCase: ...@@ -1159,7 +1159,7 @@ class TDTestCase:
""" """
thread input same stb, different tb, different data, add tag, mul col thread input same stb, different tb, different data, add tag, mul col
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
s_stb_d_tb_a_tag_m_col_list = self.genSqlList(stb_name=stb_name)[6] s_stb_d_tb_a_tag_m_col_list = self.genSqlList(stb_name=stb_name)[6]
...@@ -1171,7 +1171,7 @@ class TDTestCase: ...@@ -1171,7 +1171,7 @@ class TDTestCase:
""" """
thread input same stb tb, different ts thread input same stb tb, different ts
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -1186,7 +1186,7 @@ class TDTestCase: ...@@ -1186,7 +1186,7 @@ class TDTestCase:
""" """
thread input same stb tb, different ts, add col, mul tag thread input same stb tb, different ts, add col, mul tag
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -1205,7 +1205,7 @@ class TDTestCase: ...@@ -1205,7 +1205,7 @@ class TDTestCase:
""" """
thread input same stb tb, different ts, add tag, mul col thread input same stb tb, different ts, add tag, mul col
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
tb_name = tdCom.getLongName(7, "letters") tb_name = tdCom.getLongName(7, "letters")
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -1226,7 +1226,7 @@ class TDTestCase: ...@@ -1226,7 +1226,7 @@ class TDTestCase:
""" """
thread input same stb, different tb, data, ts thread input same stb, different tb, data, ts
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10] s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10]
...@@ -1241,7 +1241,7 @@ class TDTestCase: ...@@ -1241,7 +1241,7 @@ class TDTestCase:
""" """
thread input same stb, different tb, data, ts, add col, mul tag thread input same stb, different tb, data, ts, add col, mul tag
""" """
tdCom.cleanTb() tdCom.cleanTb(dbname="test")
input_sql, stb_name = self.genFullTypeSql() input_sql, stb_name = self.genFullTypeSql()
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
s_stb_d_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[11] s_stb_d_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[11]
......
...@@ -193,43 +193,38 @@ class TDTestCase: ...@@ -193,43 +193,38 @@ class TDTestCase:
# case17: only support normal table join # case17: only support normal table join
case17 = { case17 = {
"col": "t1.c1", "col": "table1.c1 ",
"table_expr": "t1, t2", "table_expr": "db.t1 as table1, db.t2 as table2",
"condition": "where t1.ts=t2.ts" "condition": "where table1.ts=table2.ts"
} }
self.checkdiff(**case17) self.checkdiff(**case17)
# case18~19: with group by # case18~19: with group by , function diff not support group by
# case18 = {
# "table_expr": "db.t1",
# "condition": "group by c6"
# }
# self.checkdiff(**case18)
case19 = { case19 = {
"table_expr": "db.stb1", "table_expr": "db.stb1 where tbname =='t0' ",
"condition": "partition by tbname order by tbname" # partition by tbname "condition": "partition by tbname order by tbname" # partition by tbname
} }
self.checkdiff(**case19) self.checkdiff(**case19)
# # case20~21: with order by # case20~21: with order by , Not a single-group group function
# case20 = {"condition": "order by ts"}
# self.checkdiff(**case20)
# # case22: with union # case22: with union
# case22 = { # case22 = {
# "condition": "union all select diff(c1) from t2" # "condition": "union all select diff(c1) from db.t2 "
# } # }
# self.checkdiff(**case22) # self.checkdiff(**case22)
tdSql.query("select count(c1) from db.t1 union all select count(c1) from db.t2")
# case23: with limit/slimit # case23: with limit/slimit
case23 = { case23 = {
"condition": "limit 1" "condition": "limit 1"
} }
self.checkdiff(**case23) self.checkdiff(**case23)
# case24 = { case24 = {
# "table_expr": "db.stb1", "table_expr": "db.stb1",
# "condition": "group by tbname slimit 1 soffset 1" "condition": "partition by tbname order by tbname slimit 1 soffset 1"
# } }
# self.checkdiff(**case24) self.checkdiff(**case24)
pass pass
...@@ -284,9 +279,9 @@ class TDTestCase: ...@@ -284,9 +279,9 @@ class TDTestCase:
tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1 tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1
# tdSql.error(self.diff_query_form(table_expr="db.stb1")) # select stb directly # tdSql.error(self.diff_query_form(table_expr="db.stb1")) # select stb directly
stb_join = { stb_join = {
"col": "stb1.c1", "col": "stable1.c1",
"table_expr": "stb1, stb2", "table_expr": "db.stb1 as stable1, db.stb2 as stable2",
"condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" "condition": "where stable1.ts=stable2.ts and stable1.st1=stable2.st2 order by stable1.ts"
} }
tdSql.query(self.diff_query_form(**stb_join)) # stb join tdSql.query(self.diff_query_form(**stb_join)) # stb join
interval_sql = { interval_sql = {
...@@ -315,20 +310,20 @@ class TDTestCase: ...@@ -315,20 +310,20 @@ class TDTestCase:
for i in range(tbnum): for i in range(tbnum):
for j in range(data_row): for j in range(data_row):
tdSql.execute( tdSql.execute(
f"insert into t{i} values (" f"insert into db.t{i} values ("
f"{basetime + (j+1)*10}, {random.randint(-200, -1)}, {random.uniform(200, -1)}, {basetime + random.randint(-200, -1)}, " f"{basetime + (j+1)*10}, {random.randint(-200, -1)}, {random.uniform(200, -1)}, {basetime + random.randint(-200, -1)}, "
f"'binary_{j}', {random.uniform(-200, -1)}, {random.choice([0,1])}, {random.randint(-200,-1)}, " f"'binary_{j}', {random.uniform(-200, -1)}, {random.choice([0,1])}, {random.randint(-200,-1)}, "
f"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )" f"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )"
) )
tdSql.execute( tdSql.execute(
f"insert into t{i} values (" f"insert into db.t{i} values ("
f"{basetime - (j+1) * 10}, {random.randint(1, 200)}, {random.uniform(1, 200)}, {basetime - random.randint(1, 200)}, " f"{basetime - (j+1) * 10}, {random.randint(1, 200)}, {random.uniform(1, 200)}, {basetime - random.randint(1, 200)}, "
f"'binary_{j}_1', {random.uniform(1, 200)}, {random.choice([0, 1])}, {random.randint(1,200)}, " f"'binary_{j}_1', {random.uniform(1, 200)}, {random.choice([0, 1])}, {random.randint(1,200)}, "
f"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )" f"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )"
) )
tdSql.execute( tdSql.execute(
f"insert into tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )" f"insert into db.tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )"
) )
pass pass
...@@ -349,8 +344,8 @@ class TDTestCase: ...@@ -349,8 +344,8 @@ class TDTestCase:
"create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)" "create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)"
) )
for i in range(tbnum): for i in range(tbnum):
tdSql.execute(f"create table t{i} using db.stb1 tags({i})") tdSql.execute(f"create table db.t{i} using db.stb1 tags({i})")
tdSql.execute(f"create table tt{i} using db.stb2 tags({i})") tdSql.execute(f"create table db.tt{i} using db.stb2 tags({i})")
pass pass
def diff_support_stable(self): def diff_support_stable(self):
...@@ -398,8 +393,8 @@ class TDTestCase: ...@@ -398,8 +393,8 @@ class TDTestCase:
tdLog.printNoPrefix("######## insert only NULL test:") tdLog.printNoPrefix("######## insert only NULL test:")
for i in range(tbnum): for i in range(tbnum):
tdSql.execute(f"insert into t{i}(ts) values ({nowtime - 5})") tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime - 5})")
tdSql.execute(f"insert into t{i}(ts) values ({nowtime + 5})") tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime + 5})")
self.diff_current_query() self.diff_current_query()
self.diff_error_query() self.diff_error_query()
...@@ -430,9 +425,9 @@ class TDTestCase: ...@@ -430,9 +425,9 @@ class TDTestCase:
tdLog.printNoPrefix("######## insert data mix with NULL test:") tdLog.printNoPrefix("######## insert data mix with NULL test:")
for i in range(tbnum): for i in range(tbnum):
tdSql.execute(f"insert into t{i}(ts) values ({nowtime})") tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime})")
tdSql.execute(f"insert into t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime-(per_table_rows+3)*10})")
tdSql.execute(f"insert into t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime+(per_table_rows+3)*10})")
self.diff_current_query() self.diff_current_query()
self.diff_error_query() self.diff_error_query()
......
...@@ -52,12 +52,12 @@ class TDTestCase: ...@@ -52,12 +52,12 @@ class TDTestCase:
return query_condition return query_condition
def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False): def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False, alias_tb1="tb1", alias_tb2="tb2"):
table_reference = tb_list[0] table_reference = tb_list[0]
join_condition = table_reference join_condition = table_reference
join = "inner join" if INNER else "join" join = "inner join" if INNER else "join"
for i in range(len(tb_list[1:])): for i in range(len(tb_list[1:])):
join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}" join_condition += f" as {alias_tb1} {join} {tb_list[i+1]} as {alias_tb2} on {alias_tb1}.{filter}={alias_tb2}.{filter}"
return join_condition return join_condition
...@@ -123,28 +123,28 @@ class TDTestCase: ...@@ -123,28 +123,28 @@ class TDTestCase:
sqls = [] sqls = []
__join_tblist = self.__join_tblist __join_tblist = self.__join_tblist
for join_tblist in __join_tblist: for join_tblist in __join_tblist:
for join_tb in join_tblist: alias_tb = "tb1"
select_claus_list = self.__query_condition(join_tb) select_claus_list = self.__query_condition(alias_tb)
for select_claus in select_claus_list: for select_claus in select_claus_list:
group_claus = self.__group_condition( col=select_claus) group_claus = self.__group_condition( col=select_claus)
where_claus = self.__where_condition( query_conditon=select_claus ) where_claus = self.__where_condition( query_conditon=select_claus )
having_claus = self.__group_condition( col=select_claus, having=f"{select_claus} is not null" ) having_claus = self.__group_condition( col=select_claus, having=f"{select_claus} is not null" )
sqls.extend( sqls.extend(
( (
# self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, group_claus), # self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, group_claus),
self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, having_claus), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), where_claus, having_claus),
self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), where_claus),
# self.__gen_sql(select_claus, self.__join_condition(join_tblist), group_claus), # self.__gen_sql(select_claus, self.__join_condition(join_tblist), group_claus),
self.__gen_sql(select_claus, self.__join_condition(join_tblist), having_claus), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), having_claus),
self.__gen_sql(select_claus, self.__join_condition(join_tblist)), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb)),
# self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, group_claus), # self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, group_claus),
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, having_claus), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), where_claus, having_claus),
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, ), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), where_claus, ),
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), having_claus ), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), having_claus ),
# self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), group_claus ), # self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), group_claus ),
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True) ), self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True) ),
)
) )
)
return list(filter(None, sqls)) return list(filter(None, sqls))
def __join_check(self,): def __join_check(self,):
...@@ -341,10 +341,8 @@ class TDTestCase: ...@@ -341,10 +341,8 @@ class TDTestCase:
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test()
tdDnodes.stop(1) tdSql.execute(f"flush database db")
tdDnodes.start(1)
tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test() self.all_test()
......
...@@ -65,96 +65,8 @@ class TDTestCase: ...@@ -65,96 +65,8 @@ class TDTestCase:
''' '''
) )
def check_result_auto_log(self ,base , origin_query , log_query):
def check_result_auto_log(self ,origin_query , log_query):
log_result = tdSql.getResult(log_query)
origin_result = tdSql.getResult(origin_query)
auto_result =[]
for row in origin_result:
row_check = []
for elem in row:
if elem == None:
elem = None
elif elem >0:
elem = math.log(elem)
elif elem <=0:
elem = None
row_check.append(elem)
auto_result.append(row_check)
check_status = True
for row_index , row in enumerate(log_result):
for col_index , elem in enumerate(row):
if auto_result[row_index][col_index] != elem:
check_status = False
if not check_status:
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
sys.exit(1)
else:
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
def check_result_auto_log2(self ,origin_query , log_query):
log_result = tdSql.getResult(log_query)
origin_result = tdSql.getResult(origin_query)
auto_result =[]
for row in origin_result:
row_check = []
for elem in row:
if elem == None:
elem = None
elif elem >0:
elem = math.log(elem,2)
elif elem <=0:
elem = None
row_check.append(elem)
auto_result.append(row_check)
check_status = True
for row_index , row in enumerate(log_result):
for col_index , elem in enumerate(row):
if auto_result[row_index][col_index] != elem:
check_status = False
if not check_status:
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
sys.exit(1)
else:
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
def check_result_auto_log1(self ,origin_query , log_query):
log_result = tdSql.getResult(log_query)
origin_result = tdSql.getResult(origin_query)
auto_result =[]
for row in origin_result:
row_check = []
for elem in row:
if elem == None:
elem = None
elif elem >0:
elem = None
elif elem <=0:
elem = None
row_check.append(elem)
auto_result.append(row_check)
check_status = True
for row_index , row in enumerate(log_result):
for col_index , elem in enumerate(row):
if auto_result[row_index][col_index] != elem:
check_status = False
if not check_status:
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
sys.exit(1)
else:
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
def check_result_auto_log__10(self ,origin_query , log_query):
log_result = tdSql.getResult(log_query) log_result = tdSql.getResult(log_query)
origin_result = tdSql.getResult(origin_query) origin_result = tdSql.getResult(origin_query)
...@@ -163,26 +75,30 @@ class TDTestCase: ...@@ -163,26 +75,30 @@ class TDTestCase:
for row in origin_result: for row in origin_result:
row_check = [] row_check = []
for elem in row: for elem in row:
if elem == None: if base ==1:
elem = None
elif elem >0:
elem = None
elif elem <=0:
elem = None elem = None
else:
if elem == None:
elem = None
elif elem ==1:
elem = 0.0
elif elem >0 and elem !=1 :
if base==None :
elem = math.log(elem )
else:
print(base , elem)
elem = math.log(elem , base)
elif elem <=0:
elem = None
row_check.append(elem) row_check.append(elem)
auto_result.append(row_check) auto_result.append(row_check)
check_status = True tdSql.query(log_query)
for row_index , row in enumerate(log_result): for row_index , row in enumerate(log_result):
for col_index , elem in enumerate(row): for col_index , elem in enumerate(row):
if auto_result[row_index][col_index] != elem: tdSql.checkData(row_index , col_index ,auto_result[row_index][col_index])
check_status = False
if not check_status:
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
sys.exit(1)
else:
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
def test_errors(self, dbname="db"): def test_errors(self, dbname="db"):
error_sql_lists = [ error_sql_lists = [
f"select log from {dbname}.t1", f"select log from {dbname}.t1",
...@@ -328,10 +244,10 @@ class TDTestCase: ...@@ -328,10 +244,10 @@ class TDTestCase:
tdSql.checkData(3 , 0, 1.098612289) tdSql.checkData(3 , 0, 1.098612289)
tdSql.checkData(4 , 0, 1.386294361) tdSql.checkData(4 , 0, 1.386294361)
self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.t1") self.check_result_auto_log( None , f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.t1")
self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from {dbname}.t1") self.check_result_auto_log( 2 , f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from {dbname}.t1")
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from {dbname}.t1") self.check_result_auto_log( 1, f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from {dbname}.t1")
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,-10), log(c2 ,-10) ,log(c3, -10), log(c4 ,-10), log(c5 ,-10) from {dbname}.t1") self.check_result_auto_log( 10 ,f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,10), log(c2 ,10) ,log(c3, 10), log(c4 ,10), log(c5 ,10) from {dbname}.t1")
# used for sub table # used for sub table
tdSql.query(f"select c1 ,log(c1 ,3) from {dbname}.ct1") tdSql.query(f"select c1 ,log(c1 ,3) from {dbname}.ct1")
...@@ -349,9 +265,9 @@ class TDTestCase: ...@@ -349,9 +265,9 @@ class TDTestCase:
tdSql.checkData(3 , 2, 0.147315235) tdSql.checkData(3 , 2, 0.147315235)
tdSql.checkData(4 , 2, None) tdSql.checkData(4 , 2, None)
self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.ct1") self.check_result_auto_log( None ,f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.ct1")
self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) from {dbname}.ct1") self.check_result_auto_log( 2, f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) from {dbname}.ct1")
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) from {dbname}.ct1") self.check_result_auto_log( 10 , f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,10), log(c2,10) ,log(c3,10), log(c4,10), log(c5,10) from {dbname}.ct1")
# nest query for log functions # nest query for log functions
tdSql.query(f"select c1 , log(c1,3) ,log(log(c1,3),3) , log(log(log(c1,3),3),3) from {dbname}.ct1;") tdSql.query(f"select c1 , log(c1,3) ,log(log(c1,3),3) , log(log(log(c1,3),3),3) from {dbname}.ct1;")
...@@ -585,15 +501,15 @@ class TDTestCase: ...@@ -585,15 +501,15 @@ class TDTestCase:
tdSql.error( tdSql.error(
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() )" 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_log( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from {dbname}.sub1_bound") self.check_result_auto_log(None , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from {dbname}.sub1_bound")
self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from {dbname}.sub1_bound") self.check_result_auto_log( 2 , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from {dbname}.sub1_bound")
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) ,log(c6,-10) from {dbname}.sub1_bound") self.check_result_auto_log( 10 , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,10), log(c2,10) ,log(c3,10), log(c4,10), log(c5,10) ,log(c6,10) from {dbname}.sub1_bound")
self.check_result_auto_log2( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from {dbname}.sub1_bound") self.check_result_auto_log( 2 , f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from {dbname}.sub1_bound")
self.check_result_auto_log( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from {dbname}.sub1_bound") self.check_result_auto_log( None , f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from {dbname}.sub1_bound")
self.check_result_auto_log2(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select log(abs(c1) ,2) from {dbname}.sub1_bound" ) self.check_result_auto_log(2 , f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select log(abs(c1) ,2) from {dbname}.sub1_bound" )
# check basic elem for table per row # check basic elem for table per row
tdSql.query(f"select log(abs(c1),2) ,log(abs(c2),2) , log(abs(c3),2) , log(abs(c4),2), log(abs(c5),2), log(abs(c6),2) from {dbname}.sub1_bound ") tdSql.query(f"select log(abs(c1),2) ,log(abs(c2),2) , log(abs(c3),2) , log(abs(c4),2), log(abs(c5),2), log(abs(c6),2) from {dbname}.sub1_bound ")
...@@ -647,15 +563,15 @@ class TDTestCase: ...@@ -647,15 +563,15 @@ class TDTestCase:
def support_super_table_test(self, dbname="db"): def support_super_table_test(self, dbname="db"):
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 order by ts " , f"select log(c5,2) from {dbname}.stb1 order by ts" ) self.check_result_auto_log( 2 , f"select c5 from {dbname}.stb1 order by ts " , f"select log(c5,2) from {dbname}.stb1 order by ts" )
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 order by tbname " , f"select log(c5,2) from {dbname}.stb1 order by tbname" ) self.check_result_auto_log( 2 ,f"select c5 from {dbname}.stb1 order by tbname " , f"select log(c5,2) from {dbname}.stb1 order by tbname" )
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) self.check_result_auto_log( 2 ,f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) self.check_result_auto_log( 2 , f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select log(t1,2), log(c5,2) from {dbname}.stb1 order by ts" ) self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 order by ts " , f"select log(t1,2), log(c5,2) from {dbname}.stb1 order by ts" )
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 order by tbname" ) self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 order by tbname" )
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) , log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) self.check_result_auto_log( 2 ,f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) , log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
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()
......
...@@ -96,16 +96,16 @@ class TDTestCase: ...@@ -96,16 +96,16 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): def __test_current(self, dbname="db"):
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname: for tb in tbname:
self.__lower_current_check(tb) self.__lower_current_check(tb)
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
def __test_error(self): def __test_error(self, dbname="db"):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname: for tb in tbname:
for errsql in self.__lower_err_check(tb): for errsql in self.__lower_err_check(tb):
...@@ -113,22 +113,20 @@ class TDTestCase: ...@@ -113,22 +113,20 @@ class TDTestCase:
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
def all_test(self): def all_test(self, dbname="db"):
self.__test_current() self.__test_current(dbname)
self.__test_error() self.__test_error(dbname)
def __create_tb(self, dbname="db"):
def __create_tb(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (tag1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -138,78 +136,78 @@ class TDTestCase: ...@@ -138,78 +136,78 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
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} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname="db"):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( (
{ now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000} { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000}
) )
( (
{ now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000} { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000}
) )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( (
{ now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126,
{ -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
) )
( (
{ now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127,
{ - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
) )
''' '''
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127,
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 },
"binary_limit-1", "nchar_limit-1", { now_time - 86400000 } "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
) )
( (
{ now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126,
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 },
"binary_limit-2", "nchar_limit-2", { now_time - 172800000 } "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
) )
''' '''
) )
...@@ -227,10 +225,7 @@ class TDTestCase: ...@@ -227,10 +225,7 @@ class TDTestCase:
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test()
tdDnodes.stop(1) tdSql.execute("flush database db")
tdDnodes.start(1)
tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test() self.all_test()
......
...@@ -23,6 +23,7 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ] ...@@ -23,6 +23,7 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
BOOLEAN_COL = [ BOOL_COL, ] BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL = [ TS_COL, ] TS_TYPE_COL = [ TS_COL, ]
DBNAME = "db"
class TDTestCase: class TDTestCase:
...@@ -120,16 +121,16 @@ class TDTestCase: ...@@ -120,16 +121,16 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): # sourcery skip: use-itertools-product def __test_current(self, dbname=DBNAME): # sourcery skip: use-itertools-product
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname: for tb in tbname:
self.__ltrim_check(tb) self.__ltrim_check(tb)
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
def __test_error(self): def __test_error(self, dbname=DBNAME):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname: for tb in tbname:
for errsql in self.__ltrim_err_check(tb): for errsql in self.__ltrim_err_check(tb):
...@@ -142,17 +143,16 @@ class TDTestCase: ...@@ -142,17 +143,16 @@ class TDTestCase:
self.__test_error() self.__test_error()
def __create_tb(self): def __create_tb(self, dbname=DBNAME):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (t1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -162,29 +162,29 @@ class TDTestCase: ...@@ -162,29 +162,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
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} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname=DBNAME):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -200,7 +200,7 @@ class TDTestCase: ...@@ -200,7 +200,7 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -216,13 +216,13 @@ class TDTestCase: ...@@ -216,13 +216,13 @@ class TDTestCase:
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -251,8 +251,7 @@ class TDTestCase: ...@@ -251,8 +251,7 @@ class TDTestCase:
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test()
tdDnodes.stop(1) tdSql.execute("flush database db")
tdDnodes.start(1)
tdSql.execute("use db") tdSql.execute("use db")
......
...@@ -307,7 +307,7 @@ class TDTestCase: ...@@ -307,7 +307,7 @@ class TDTestCase:
pass pass
def mavg_current_query(self) : def mavg_current_query(self, dbname="db") :
# table schema :ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool # table schema :ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool
# c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16) # c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16)
...@@ -325,17 +325,17 @@ class TDTestCase: ...@@ -325,17 +325,17 @@ class TDTestCase:
case6 = {"col": "c9"} case6 = {"col": "c9"}
self.checkmavg(**case6) self.checkmavg(**case6)
# # case7~8: nested query # case7~8: nested query
# case7 = {"table_expr": f"(select c1 from {dbname}.stb1)"} case7 = {"table_expr": f"(select c1 from {dbname}.stb1)"}
# self.checkmavg(**case7) self.checkmavg(**case7)
# case8 = {"table_expr": f"(select mavg(c1, 1) c1 from {dbname}.stb1 group by tbname)"} # case8 = {"table_expr": f"(select _c0, mavg(c1, 1) c1 from {dbname}.stb1 group by tbname)"}
# self.checkmavg(**case8) # self.checkmavg(**case8)
# case9~10: mix with tbname/ts/tag/col # case9~10: mix with tbname/ts/tag/col
# case9 = {"alias": ", tbname"} case9 = {"alias": ", tbname"}
# self.checkmavg(**case9) self.checkmavg(**case9)
# case10 = {"alias": ", _c0"} case10 = {"alias": ", _c0"}
# self.checkmavg(**case10) self.checkmavg(**case10)
# case11 = {"alias": ", st1"} # case11 = {"alias": ", st1"}
# self.checkmavg(**case11) # self.checkmavg(**case11)
# case12 = {"alias": ", c1"} # case12 = {"alias": ", c1"}
...@@ -356,7 +356,7 @@ class TDTestCase: ...@@ -356,7 +356,7 @@ class TDTestCase:
# case17: only support normal table join # case17: only support normal table join
case17 = { case17 = {
"col": "t1.c1", "col": "t1.c1",
"table_expr": "t1, t2", "table_expr": f"{dbname}.t1 t1, {dbname}.t2 t2",
"condition": "where t1.ts=t2.ts" "condition": "where t1.ts=t2.ts"
} }
self.checkmavg(**case17) self.checkmavg(**case17)
...@@ -367,14 +367,14 @@ class TDTestCase: ...@@ -367,14 +367,14 @@ class TDTestCase:
# } # }
# self.checkmavg(**case19) # self.checkmavg(**case19)
# case20~21: with order by # # case20~21: with order by
# case20 = {"condition": "order by ts"} # case20 = {"condition": "order by ts"}
# self.checkmavg(**case20) # self.checkmavg(**case20)
#case21 = { case21 = {
# "table_expr": f"{dbname}.stb1", "table_expr": f"{dbname}.stb1",
# "condition": "group by tbname order by tbname" "condition": "group by tbname order by tbname"
#} }
#self.checkmavg(**case21) self.checkmavg(**case21)
# # case22: with union # # case22: with union
# case22 = { # case22 = {
...@@ -398,7 +398,7 @@ class TDTestCase: ...@@ -398,7 +398,7 @@ class TDTestCase:
pass pass
def mavg_error_query(self) -> None : def mavg_error_query(self, dbname="db") -> None :
# unusual test # unusual test
# form test # form test
...@@ -419,9 +419,9 @@ class TDTestCase: ...@@ -419,9 +419,9 @@ class TDTestCase:
err8 = {"table_expr": ""} err8 = {"table_expr": ""}
self.checkmavg(**err8) # no table_expr self.checkmavg(**err8) # no table_expr
# err9 = {"col": "st1"} err9 = {"col": "st1"}
# self.checkmavg(**err9) # col: tag # self.checkmavg(**err9) # col: tag
# err10 = {"col": 1} err10 = {"col": 1}
# self.checkmavg(**err10) # col: value # self.checkmavg(**err10) # col: value
err11 = {"col": "NULL"} err11 = {"col": "NULL"}
self.checkmavg(**err11) # col: NULL self.checkmavg(**err11) # col: NULL
...@@ -496,7 +496,7 @@ class TDTestCase: ...@@ -496,7 +496,7 @@ class TDTestCase:
# "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" # "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts"
# } # }
# self.checkmavg(**err44) # stb join # self.checkmavg(**err44) # stb join
tdSql.query("select mavg( stb1.c1 , 1 ) from stb1, stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;") tdSql.query(f"select mavg( stb1.c1 , 1 ) from {dbname}.stb1 stb1, {dbname}.stb2 stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;")
err45 = { err45 = {
"condition": "where ts>0 and ts < now interval(1h) fill(next)" "condition": "where ts>0 and ts < now interval(1h) fill(next)"
} }
......
...@@ -5,10 +5,7 @@ import numpy as np ...@@ -5,10 +5,7 @@ import numpy as np
class TDTestCase: class TDTestCase:
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
"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,
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
...@@ -17,60 +14,57 @@ class TDTestCase: ...@@ -17,60 +14,57 @@ class TDTestCase:
self.ts = 1537146000000 self.ts = 1537146000000
self.binary_str = 'taosdata' self.binary_str = 'taosdata'
self.nchar_str = '涛思数据' self.nchar_str = '涛思数据'
def max_check_stb_and_tb_base(self): def max_check_stb_and_tb_base(self, dbname="db"):
tdSql.prepare() tdSql.prepare()
intData = [] intData = []
floatData = [] floatData = []
tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''')
tdSql.execute("create table stb_1 using stb tags('beijing')") tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
intData.append(i + 1) intData.append(i + 1)
floatData.append(i + 0.1) floatData.append(i + 0.1)
for i in ['ts','col11','col12','col13']: for i in ['ts','col11','col12','col13']:
for j in ['db.stb','stb','db.stb_1','stb_1']: for j in ['stb','stb_1']:
tdSql.error(f'select max({i} from {j} )') tdSql.error(f'select max({i} from {dbname}.{j} )')
for i in range(1,11): for i in range(1,11):
for j in ['db.stb','stb','db.stb_1','stb_1']: for j in ['stb', 'stb_1']:
tdSql.query(f"select max(col{i}) from {j}") tdSql.query(f"select max(col{i}) from {dbname}.{j}")
if i<9: if i<9:
tdSql.checkData(0, 0, np.max(intData)) tdSql.checkData(0, 0, np.max(intData))
elif i>=9: elif i>=9:
tdSql.checkData(0, 0, np.max(floatData)) tdSql.checkData(0, 0, np.max(floatData))
tdSql.query("select max(col1) from stb_1 where col2<=5") tdSql.query(f"select max(col1) from {dbname}.stb_1 where col2<=5")
tdSql.checkData(0,0,5) tdSql.checkData(0,0,5)
tdSql.query("select max(col1) from stb where col2<=5") tdSql.query(f"select max(col1) from {dbname}.stb where col2<=5")
tdSql.checkData(0,0,5) tdSql.checkData(0,0,5)
tdSql.execute('drop database db')
def max_check_ntb_base(self): def max_check_ntb_base(self, dbname="db"):
tdSql.prepare() tdSql.prepare()
intData = [] intData = []
floatData = [] floatData = []
tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, tdSql.execute(f'''create table {dbname}.ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20))''') col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20))''')
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute(f"insert into ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
intData.append(i + 1) intData.append(i + 1)
floatData.append(i + 0.1) floatData.append(i + 0.1)
for i in ['ts','col11','col12','col13']: for i in ['ts','col11','col12','col13']:
for j in ['db.ntb','ntb']: for j in ['ntb']:
tdSql.error(f'select max({i} from {j} )') tdSql.error(f'select max({i} from {dbname}.{j} )')
for i in range(1,11): for i in range(1,11):
for j in ['db.ntb','ntb']: for j in ['ntb']:
tdSql.query(f"select max(col{i}) from {j}") tdSql.query(f"select max(col{i}) from {dbname}.{j}")
if i<9: if i<9:
tdSql.checkData(0, 0, np.max(intData)) tdSql.checkData(0, 0, np.max(intData))
elif i>=9: elif i>=9:
tdSql.checkData(0, 0, np.max(floatData)) tdSql.checkData(0, 0, np.max(floatData))
tdSql.query("select max(col1) from ntb where col2<=5") tdSql.query(f"select max(col1) from {dbname}.ntb where col2<=5")
tdSql.checkData(0,0,5) tdSql.checkData(0,0,5)
tdSql.execute('drop database db')
def check_max_functions(self, tbname , col_name): def check_max_functions(self, tbname , col_name):
...@@ -90,55 +84,55 @@ class TDTestCase: ...@@ -90,55 +84,55 @@ class TDTestCase:
tdLog.info(" max function work as expected, sql : %s "% max_sql) tdLog.info(" max function work as expected, sql : %s "% max_sql)
def support_distributed_aggregate(self): def support_distributed_aggregate(self, dbname="testdb"):
# prepate datas for 20 tables distributed at different vgroups # prepate datas for 20 tables distributed at different vgroups
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
tdSql.execute(" use testdb ") tdSql.execute(f"use {dbname} ")
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 (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
''' '''
) )
tdSql.execute( 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(20): for i in range(20):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
for i in range(9): 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 )"
) )
for i in range(1,21): for i in range(1,21):
if i ==1 or i == 4: if i ==1 or i == 4:
continue continue
else: else:
tbname = "ct"+f'{i}' tbname = f"{dbname}.ct{i}"
for j in range(9): for j in range(9):
tdSql.execute( tdSql.execute(
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}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 )
...@@ -157,7 +151,7 @@ class TDTestCase: ...@@ -157,7 +151,7 @@ class TDTestCase:
tdLog.info(" prepare data for distributed_aggregate done! ") tdLog.info(" prepare data for distributed_aggregate done! ")
# get vgroup_ids of all # get vgroup_ids of all
tdSql.query("show vgroups ") tdSql.query(f"show {dbname}.vgroups ")
vgroups = tdSql.queryResult vgroups = tdSql.queryResult
vnode_tables={} vnode_tables={}
...@@ -167,7 +161,7 @@ class TDTestCase: ...@@ -167,7 +161,7 @@ class TDTestCase:
# check sub_table of per vnode ,make sure sub_table has been distributed # check sub_table of per vnode ,make sure sub_table has been distributed
tdSql.query("select * from information_schema.ins_tables where db_name = 'testdb' and table_name like 'ct%'") tdSql.query(f"select * from information_schema.ins_tables where db_name = '{dbname}' and table_name like 'ct%'")
table_names = tdSql.queryResult table_names = tdSql.queryResult
tablenames = [] tablenames = []
for table_name in table_names: for table_name in table_names:
...@@ -182,13 +176,13 @@ class TDTestCase: ...@@ -182,13 +176,13 @@ class TDTestCase:
# check max function work status # check max function work status
tdSql.query("show tables like 'ct%'") tdSql.query(f"show {dbname}.tables like 'ct%'")
table_names = tdSql.queryResult table_names = tdSql.queryResult
tablenames = [] tablenames = []
for table_name in table_names: for table_name in table_names:
tablenames.append(table_name[0]) tablenames.append(table_name[0])
tdSql.query("desc stb1") tdSql.query(f"desc {dbname}.stb1")
col_names = tdSql.queryResult col_names = tdSql.queryResult
colnames = [] colnames = []
...@@ -198,11 +192,7 @@ class TDTestCase: ...@@ -198,11 +192,7 @@ class TDTestCase:
for tablename in tablenames: for tablename in tablenames:
for colname in colnames: for colname in colnames:
self.check_max_functions(tablename,colname) self.check_max_functions(f"{dbname}.{tablename}", colname)
# max function with basic filter
print(vnode_tables)
def run(self): def run(self):
......
...@@ -12,16 +12,15 @@ class TDTestCase: ...@@ -12,16 +12,15 @@ class TDTestCase:
self.tb_nums = 10 self.tb_nums = 10
self.ts = 1537146000000 self.ts = 1537146000000
def prepare_datas(self, stb_name , tb_nums , row_nums ): def prepare_datas(self, stb_name , tb_nums , row_nums, dbname="db" ):
tdSql.execute(" use db ") tdSql.execute(f" create stable {dbname}.{stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\ uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ") , t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
for i in range(tb_nums): for i in range(tb_nums):
tbname = f"sub_{stb_name}_{i}" tbname = f"{dbname}.sub_{stb_name}_{i}"
ts = self.ts + i*10000 ts = self.ts + i*10000
tdSql.execute(f"create table {tbname} using {stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
for row in range(row_nums): for row in range(row_nums):
ts = self.ts + row*1000 ts = self.ts + row*1000
...@@ -31,191 +30,192 @@ class TDTestCase: ...@@ -31,191 +30,192 @@ class TDTestCase:
ts = self.ts + row_nums*1000 + null*1000 ts = self.ts + row_nums*1000 + null*1000
tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )") tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )")
def basic_query(self): def basic_query(self, dbname="db"):
tdSql.query("select count(*) from stb") tdSql.query(f"select count(*) from {dbname}.stb")
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums) tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
tdSql.query("select max(c1) from stb") tdSql.query(f"select max(c1) from {dbname}.stb")
tdSql.checkData(0,0,(self.row_nums -1)) tdSql.checkData(0,0,(self.row_nums -1))
tdSql.query(" select tbname , max(c1) from stb partition by tbname ") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.query(" select max(c1) from stb group by t1 order by t1 ") tdSql.query(f"select max(c1) from {dbname}.stb group by t1 order by t1 ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.query(" select max(c1) from stb group by c1 order by t1 ") tdSql.query(f"select max(c1) from {dbname}.stb group by c1 order by t1 ")
tdSql.query(" select max(t2) from stb group by c1 order by t1 ") tdSql.query(f"select max(t2) from {dbname}.stb group by c1 order by t1 ")
tdSql.query(" select max(c1) from stb group by tbname order by tbname ") tdSql.query(f"select max(c1) from {dbname}.stb group by tbname order by tbname ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
# bug need fix # bug need fix
tdSql.query(" select max(t2) from stb group by t2 order by t2 ") tdSql.query(f"select max(t2) from {dbname}.stb group by t2 order by t2 ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.query(" select max(c1) from stb group by c1 order by c1 ") tdSql.query(f"select max(c1) from {dbname}.stb group by c1 order by c1 ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query(" select c1 , max(c1) from stb group by c1 order by c1 ") tdSql.query(f"select c1 , max(c1) from {dbname}.stb group by c1 order by c1 ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
# support selective functions # support selective functions
tdSql.query(" select c1 ,c2 ,c3 , max(c1) ,c4 ,c5 ,t11 from stb group by c1 order by c1 desc ") tdSql.query(f"select c1 ,c2 ,c3 , max(c1) ,c4 ,c5 ,t11 from {dbname}.stb group by c1 order by c1 desc ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query(" select c1, tbname , max(c1) ,c4 ,c5 ,t11 from stb group by c1 order by c1 desc ") tdSql.query(f"select c1, tbname , max(c1) ,c4 ,c5 ,t11 from {dbname}.stb group by c1 order by c1 desc ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
# bug need fix # bug need fix
# tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ") tdSql.query(f"select tbname , max(c1) from {dbname}.sub_stb_1 where c1 is null group by c1 order by c1 desc ")
# tdSql.checkRows(1) tdSql.checkRows(1)
# tdSql.checkData(0,0,"sub_stb_1") tdSql.checkData(0,0,"sub_stb_1")
tdSql.query("select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)") tdSql.query(f"select max(c1) ,c2 ,t2,tbname from {dbname}.stb group by abs(c1) order by abs(c1)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select abs(c1+c3), count(c1+c3) ,max(c1+t2) from stb group by abs(c1+c3) order by abs(c1+c3)") tdSql.query(f"select abs(c1+c3), count(c1+c3) ,max(c1+t2) from {dbname}.stb group by abs(c1+c3) order by abs(c1+c3)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select max(c1+c3)+min(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)") tdSql.query(f"select max(c1+c3)+min(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from stb group by abs(c1) order by abs(t1)+c2") tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from {dbname}.stb group by abs(c1) order by abs(t1)+c2")
tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)+c2") tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)+c2")
tdSql.query("select abs(c1+c3)+abs(c2) , count(c1+c3)+max(c2) from stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)") tdSql.query(f"select abs(c1+c3)+abs(c2) , count(c1+c3)+max(c2) from {dbname}.stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query(" select max(c1) , max(t2) from stb where abs(c1+t2)=1 partition by tbname ") tdSql.query(f"select max(c1) , max(t2) from {dbname}.stb where abs(c1+t2)=1 partition by tbname ")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query(" select max(c1) from stb where abs(c1+t2)=1 partition by tbname ") tdSql.query(f"select max(c1) from {dbname}.stb where abs(c1+t2)=1 partition by tbname ")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname ") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,1,self.row_nums-1) tdSql.checkData(0,1,self.row_nums-1)
tdSql.query("select tbname , max(c2) from stb partition by t1 order by t1") tdSql.query(f"select tbname , max(c2) from {dbname}.stb partition by t1 order by t1")
tdSql.query("select tbname , max(t2) from stb partition by t1 order by t1") tdSql.query(f"select tbname , max(t2) from {dbname}.stb partition by t1 order by t1")
tdSql.query("select tbname , max(t2) from stb partition by t2 order by t2") tdSql.query(f"select tbname , max(t2) from {dbname}.stb partition by t2 order by t2")
# # bug need fix # # bug need fix
tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2") tdSql.query(f"select t2 , max(t2) from {dbname}.stb partition by t2 order by t2")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.query("select tbname , max(c1) from stb partition by tbname order by tbname") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,1,self.row_nums-1) tdSql.checkData(0,1,self.row_nums-1)
tdSql.query("select tbname , max(c1) from stb partition by t2 order by t2") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by t2 order by t2")
tdSql.query("select c2, max(c1) from stb partition by c2 order by c2 desc") tdSql.query(f"select c2, max(c1) from {dbname}.stb partition by c2 order by c2 desc")
tdSql.checkRows(self.tb_nums+1) tdSql.checkRows(self.tb_nums+1)
tdSql.checkData(0,1,self.row_nums-1) tdSql.checkData(0,1,self.row_nums-1)
tdSql.query("select tbname , max(c1) from stb partition by c1 order by c2") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by c1 order by c2")
tdSql.query("select tbname , abs(t2) from stb partition by c2 order by t2") tdSql.query(f"select tbname , abs(t2) from {dbname}.stb partition by c2 order by t2")
tdSql.checkRows(self.tb_nums*(self.row_nums+5)) tdSql.checkRows(self.tb_nums*(self.row_nums+5))
tdSql.query("select max(c1) , count(t2) from stb partition by c2 ") tdSql.query(f"select max(c1) , count(t2) from {dbname}.stb partition by c2 ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.checkData(0,1,self.row_nums) tdSql.checkData(0,1,self.row_nums)
tdSql.query("select count(c1) , max(t2) ,c2 from stb partition by c2 order by c2") tdSql.query(f"select count(c1) , max(t2) ,c2 from {dbname}.stb partition by c2 order by c2")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(c1) , count(t1) ,max(c2) ,tbname from stb partition by tbname order by tbname") tdSql.query(f"select count(c1) , count(t1) ,max(c2) ,tbname from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkCols(4) tdSql.checkCols(4)
tdSql.query("select count(c1) , max(t2) ,t1 from stb partition by t1 order by t1") tdSql.query(f"select count(c1) , max(t2) ,t1 from {dbname}.stb partition by t1 order by t1")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,0,self.row_nums) tdSql.checkData(0,0,self.row_nums)
# bug need fix # bug need fix
tdSql.query("select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)") tdSql.query(f"select count(c1) , max(t2) ,abs(c1) from {dbname}.stb partition by abs(c1) order by abs(c1)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)") tdSql.query(f"select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from {dbname}.stb partition by abs(c2) order by abs(c2)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select max(ceil(c1-2)) , max(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))") tdSql.query(f"select max(ceil(c1-2)) , max(floor(t2+1)) ,max(c2-c1) from {dbname}.stb partition by abs(floor(c1)) order by abs(floor(c1))")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select tbname , max(c1) ,c1 from stb partition by tbname order by tbname") tdSql.query(f"select tbname , max(c1) ,c1 from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,0,'sub_stb_0') tdSql.checkData(0,0,'sub_stb_0')
tdSql.checkData(0,1,9) tdSql.checkData(0,1,9)
tdSql.checkData(0,2,9) tdSql.checkData(0,2,9)
tdSql.query("select tbname ,top(c1,1) ,c1 from stb partition by tbname order by tbname") tdSql.query(f"select tbname ,top(c1,1) ,c1 from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.query(" select c1 , sample(c1,2) from stb partition by tbname order by tbname ") tdSql.query(f"select c1 , sample(c1,2) from {dbname}.stb partition by tbname order by tbname ")
tdSql.checkRows(self.tb_nums*2) tdSql.checkRows(self.tb_nums*2)
# interval # interval
tdSql.query("select max(c1) from stb interval(2s) sliding(1s)") tdSql.query(f"select max(c1) from {dbname}.stb interval(2s) sliding(1s)")
# bug need fix # bug need fix
tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)') tdSql.query(f'select max(c1) from {dbname}.stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)')
tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ") tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s) slimit 5 soffset 1 ")
tdSql.query("select tbname , max(c1) from stb partition by tbname interval(10s)") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname interval(10s)")
tdSql.checkRows(self.row_nums*2) tdSql.checkRows(self.row_nums*2)
tdSql.query("select unique(c1) from stb partition by tbname order by tbname") tdSql.query(f"select unique(c1) from {dbname}.stb partition by tbname order by tbname")
tdSql.query("select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s)") tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s)")
tdSql.checkData(0,0,'sub_stb_1') tdSql.checkData(0,0,'sub_stb_1')
tdSql.checkData(0,1,self.row_nums) tdSql.checkData(0,1,self.row_nums)
tdSql.query("select c1 , mavg(c1 ,2 ) from stb partition by c1") tdSql.query(f"select c1 , mavg(c1 ,2 ) from {dbname}.stb partition by c1")
tdSql.checkRows(90) tdSql.checkRows(90)
tdSql.query("select c1 , diff(c1 , 0) from stb partition by c1") tdSql.query(f"select c1 , diff(c1 , 0) from {dbname}.stb partition by c1")
tdSql.checkRows(90) tdSql.checkRows(90)
tdSql.query("select c1 , csum(c1) from stb partition by c1") tdSql.query(f"select c1 , csum(c1) from {dbname}.stb partition by c1")
tdSql.checkRows(100) tdSql.checkRows(100)
tdSql.query("select c1 , sample(c1,2) from stb partition by c1 order by c1") tdSql.query(f"select c1 , sample(c1,2) from {dbname}.stb partition by c1 order by c1")
tdSql.checkRows(21) tdSql.checkRows(21)
# bug need fix # bug need fix
# tdSql.checkData(0,1,None) tdSql.checkData(0,1,None)
tdSql.query("select c1 , twa(c1) from stb partition by c1 order by c1") tdSql.query(f"select c1 , twa(c1) from {dbname}.stb partition by c1 order by c1")
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.checkData(0,1,None) tdSql.checkData(0,1,None)
tdSql.query("select c1 , irate(c1) from stb partition by c1 order by c1") tdSql.query(f"select c1 , irate(c1) from {dbname}.stb partition by c1 order by c1")
tdSql.checkRows(11) tdSql.checkRows(11)
tdSql.checkData(0,1,None) tdSql.checkData(0,1,None)
tdSql.query("select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1") tdSql.query(f"select c1 , DERIVATIVE(c1,2,1) from {dbname}.stb partition by c1 order by c1")
tdSql.checkRows(90) tdSql.checkRows(90)
# bug need fix # bug need fix
tdSql.checkData(0,1,None) tdSql.checkData(0,1,None)
tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ") tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 0 ")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query(" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ") tdSql.query(f"select tbname , max(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)') tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
tdSql.query(f'select tbname , max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)') tdSql.query(f'select tbname , max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
def run(self): def run(self):
dbname = "db"
tdSql.prepare() tdSql.prepare()
self.prepare_datas("stb",self.tb_nums,self.row_nums) self.prepare_datas("stb",self.tb_nums,self.row_nums)
self.basic_query() self.basic_query()
# # coverage case for taosd crash about bug fix # # coverage case for taosd crash about bug fix
tdSql.query(" select sum(c1) from stb where t2+10 >1 ") tdSql.query(f"select sum(c1) from {dbname}.stb where t2+10 >1 ")
tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ") tdSql.query(f"select count(c1),count(t1) from {dbname}.stb where -t2<1 ")
tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ") tdSql.query(f"select tbname ,max(ceil(c1)) from {dbname}.stb group by tbname ")
tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ") tdSql.query(f"select avg(abs(c1)) , tbname from {dbname}.stb group by tbname ")
tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ") tdSql.query(f"select t1,c1 from {dbname}.stb where abs(t2+c1)=1 ")
def stop(self): def stop(self):
......
...@@ -14,196 +14,124 @@ class TDTestCase: ...@@ -14,196 +14,124 @@ class TDTestCase:
self.ts = 1537146000000 self.ts = 1537146000000
def run(self): def run(self):
dbname = "db"
tdSql.prepare() tdSql.prepare()
intData = [] intData = []
floatData = [] floatData = []
tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
tdSql.execute("create table stb_1 using stb tags('beijing')") tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, tdSql.execute(f'''create table {dbname}.ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''')
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute("insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
intData.append(i + 1) intData.append(i + 1)
floatData.append(i + 0.1) floatData.append(i + 0.1)
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
intData.append(i + 1) intData.append(i + 1)
floatData.append(i + 0.1) floatData.append(i + 0.1)
# max verifacation # max verifacation
tdSql.error("select min(ts) from stb_1") tdSql.error(f"select min(ts) from {dbname}.stb_1")
tdSql.error("select min(ts) from db.stb_1") tdSql.error(f"select min(col7) from {dbname}.stb_1")
tdSql.error("select min(col7) from stb_1") tdSql.error(f"select min(col8) from {dbname}.stb_1")
tdSql.error("select min(col7) from db.stb_1") tdSql.error(f"select min(col9) from {dbname}.stb_1")
tdSql.error("select min(col8) from stb_1") tdSql.error(f"select min(a) from {dbname}.stb_1")
tdSql.error("select min(col8) from db.stb_1") tdSql.query(f"select min(1) from {dbname}.stb_1")
tdSql.error("select min(col9) from stb_1") tdSql.error(f"select min(now()) from {dbname}.stb_1")
tdSql.error("select min(col9) from db.stb_1") tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1")
# tdSql.error("select min(a) from stb_1")
# tdSql.error("select min(1) from stb_1")
tdSql.error("select min(now()) from stb_1")
tdSql.error("select min(count(c1),count(c2)) from stb_1")
tdSql.query("select min(col1) from stb_1") tdSql.query(f"select min(col1) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col1) from db.stb_1") tdSql.query(f"select min(col2) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from stb_1") tdSql.query(f"select min(col3) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from db.stb_1") tdSql.query(f"select min(col4) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from stb_1") tdSql.query(f"select min(col11) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from db.stb_1") tdSql.query(f"select min(col12) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from stb_1") tdSql.query(f"select min(col13) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from db.stb_1") tdSql.query(f"select min(col14) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from stb_1") tdSql.query(f"select min(col5) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col5) from stb_1")
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col5) from db.stb_1") tdSql.query(f"select min(col6) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from stb_1") tdSql.query(f"select min(col1) from {dbname}.stb_1 where col2>=5")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from db.stb_1")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col1) from stb_1 where col2>=5")
tdSql.checkData(0,0,5) tdSql.checkData(0,0,5)
tdSql.error("select min(ts) from stb_1") tdSql.error(f"select min(ts) from {dbname}.stb_1")
tdSql.error("select min(ts) from db.stb_1") tdSql.error(f"select min(col7) from {dbname}.stb_1")
tdSql.error("select min(col7) from stb_1") tdSql.error(f"select min(col8) from {dbname}.stb_1")
tdSql.error("select min(col7) from db.stb_1") tdSql.error(f"select min(col9) from {dbname}.stb_1")
tdSql.error("select min(col8) from stb_1") tdSql.error(f"select min(a) from {dbname}.stb_1")
tdSql.error("select min(col8) from db.stb_1") tdSql.query(f"select min(1) from {dbname}.stb_1")
tdSql.error("select min(col9) from stb_1") tdSql.error(f"select min(now()) from {dbname}.stb_1")
tdSql.error("select min(col9) from db.stb_1") tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1")
# tdSql.error("select min(a) from stb_1")
# tdSql.error("select min(1) from stb_1")
tdSql.error("select min(now()) from stb_1")
tdSql.error("select min(count(c1),count(c2)) from stb_1")
tdSql.query("select min(col1) from stb") tdSql.query(f"select min(col1) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col1) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from db.stb") tdSql.query(f"select min(col2) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from stb") tdSql.query(f"select min(col3) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from db.stb") tdSql.query(f"select min(col4) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from stb") tdSql.query(f"select min(col11) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from db.stb") tdSql.query(f"select min(col12) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from stb") tdSql.query(f"select min(col13) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from db.stb") tdSql.query(f"select min(col14) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from stb") tdSql.query(f"select min(col5) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col5) from stb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col5) from db.stb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from stb")
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from db.stb") tdSql.query(f"select min(col6) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col1) from stb where col2>=5") tdSql.query(f"select min(col1) from {dbname}.stb where col2>=5")
tdSql.checkData(0,0,5) tdSql.checkData(0,0,5)
tdSql.error(f"select min(ts) from {dbname}.ntb")
tdSql.error(f"select min(col7) from {dbname}.ntb")
tdSql.error(f"select min(col8) from {dbname}.ntb")
tdSql.error(f"select min(col9) from {dbname}.ntb")
tdSql.error(f"select min(a) from {dbname}.ntb")
tdSql.query(f"select min(1) from {dbname}.ntb")
tdSql.error(f"select min(now()) from {dbname}.ntb")
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.ntb")
tdSql.error("select min(ts) from ntb") tdSql.query(f"select min(col1) from {dbname}.ntb")
tdSql.error("select min(ts) from db.ntb")
tdSql.error("select min(col7) from ntb")
tdSql.error("select min(col7) from db.ntb")
tdSql.error("select min(col8) from ntb")
tdSql.error("select min(col8) from db.ntb")
tdSql.error("select min(col9) from ntb")
tdSql.error("select min(col9) from db.ntb")
# tdSql.error("select min(a) from stb_1")
# tdSql.error("select min(1) from stb_1")
tdSql.error("select min(now()) from ntb")
tdSql.error("select min(count(c1),count(c2)) from ntb")
tdSql.query("select min(col1) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col1) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from db.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from ntb") tdSql.query(f"select min(col2) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from db.ntb") tdSql.query(f"select min(col3) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from ntb") tdSql.query(f"select min(col4) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from db.ntb") tdSql.query(f"select min(col11) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from ntb") tdSql.query(f"select min(col12) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from db.ntb") tdSql.query(f"select min(col13) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from ntb") tdSql.query(f"select min(col14) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData)) tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from db.ntb") tdSql.query(f"select min(col5) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col5) from ntb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col5) from db.ntb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from ntb")
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from db.ntb") tdSql.query(f"select min(col6) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(floatData)) tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col1) from ntb where col2>=5") tdSql.query(f"select min(col1) from {dbname}.ntb where col2>=5")
tdSql.checkData(0,0,5) tdSql.checkData(0,0,5)
......
...@@ -24,9 +24,6 @@ from util.dnodes import tdDnodes ...@@ -24,9 +24,6 @@ from util.dnodes import tdDnodes
from util.dnodes import * from util.dnodes import *
class TDTestCase: class TDTestCase:
updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
......
此差异已折叠。
...@@ -13,9 +13,9 @@ from util.common import * ...@@ -13,9 +13,9 @@ from util.common import *
sys.path.append("./6-cluster/") sys.path.append("./6-cluster/")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import threading import threading
class TDTestCase: class TDTestCase:
...@@ -28,7 +28,7 @@ class TDTestCase: ...@@ -28,7 +28,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(), True) tdSql.init(conn.cursor(), False)
def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1):
tsql.execute("use %s" %dbName) tsql.execute("use %s" %dbName)
...@@ -47,7 +47,7 @@ class TDTestCase: ...@@ -47,7 +47,7 @@ class TDTestCase:
sql = pre_create sql = pre_create
if sql != pre_create: if sql != pre_create:
tsql.execute(sql) tsql.execute(sql)
tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName))
return return
...@@ -55,7 +55,7 @@ class TDTestCase: ...@@ -55,7 +55,7 @@ class TDTestCase:
dbname="db_tsbs" dbname="db_tsbs"
stabname1="readings" stabname1="readings"
stabname2="diagnostics" stabname2="diagnostics"
ctbnamePre1="rct" ctbnamePre1="rct"
ctbnamePre2="dct" ctbnamePre2="dct"
ctbNums=40 ctbNums=40
self.ctbNums=ctbNums self.ctbNums=ctbNums
...@@ -73,7 +73,7 @@ class TDTestCase: ...@@ -73,7 +73,7 @@ class TDTestCase:
self.create_ctable(tsql=tdSql,dbName=dbname,stbName=stabname2,ctbPrefix=ctbnamePre2,ctbNum=ctbNums) self.create_ctable(tsql=tdSql,dbName=dbname,stbName=stabname2,ctbPrefix=ctbnamePre2,ctbNum=ctbNums)
for j in range(ctbNums): for j in range(ctbNums):
for i in range(rowNUms): for i in range(rowNUms):
tdSql.execute( tdSql.execute(
f"insert into rct{j} values ( {ts+i*60000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )" f"insert into rct{j} values ( {ts+i*60000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )"
...@@ -109,19 +109,19 @@ class TDTestCase: ...@@ -109,19 +109,19 @@ class TDTestCase:
def tsbsIotQuery(self,tdSql): def tsbsIotQuery(self,tdSql):
tdSql.execute("use db_tsbs") tdSql.execute("use db_tsbs")
# test interval and partition # test interval and partition
tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ") tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ")
# print(tdSql.queryResult) # print(tdSql.queryResult)
parRows=tdSql.queryRows parRows=tdSql.queryRows
tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ")
tdSql.checkRows(parRows) tdSql.checkRows(parRows)
# # test insert into # # test insert into
# tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") # tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;")
# tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") # tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);")
# tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") # tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);")
...@@ -141,7 +141,7 @@ class TDTestCase: ...@@ -141,7 +141,7 @@ class TDTestCase:
tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;") tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;")
# 2 stationary-trucks # 2 stationary-trucks
tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1)") tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1)")
tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name") tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name")
...@@ -156,7 +156,7 @@ class TDTestCase: ...@@ -156,7 +156,7 @@ class TDTestCase:
tdSql.query("select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from readings where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(1d) ;") tdSql.query("select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from readings where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(1d) ;")
# # 6. avg-daily-driving-session # # 6. avg-daily-driving-session
# #taosc core dumped # #taosc core dumped
# tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))") # tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))")
# tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;") # tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;")
...@@ -166,7 +166,7 @@ class TDTestCase: ...@@ -166,7 +166,7 @@ class TDTestCase:
# 7. avg-load # 7. avg-load
tdSql.query("SELECT fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml FROM diagnostics partition BY name, fleet, model) partition BY fleet, model order by fleet ;") tdSql.query("SELECT fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml FROM diagnostics partition BY name, fleet, model) partition BY fleet, model order by fleet ;")
# 8. daily-activity # 8. daily-activity
tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;")
tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;")
...@@ -184,7 +184,7 @@ class TDTestCase: ...@@ -184,7 +184,7 @@ class TDTestCase:
tdSql.query(" SELECT model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;") tdSql.query(" SELECT model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;")
#it's already supported: #it's already supported:
# last-loc # last-loc
tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;") tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;")
...@@ -192,7 +192,7 @@ class TDTestCase: ...@@ -192,7 +192,7 @@ class TDTestCase:
#2. low-fuel #2. low-fuel
tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;") tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;")
# 3. avg-vs-projected-fuel-consumption # 3. avg-vs-projected-fuel-consumption
tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet") tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet")
...@@ -213,16 +213,16 @@ class TDTestCase: ...@@ -213,16 +213,16 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
tdSql.query("select * from information_schema.ins_dnodes;") tdSql.query("select * from information_schema.ins_dnodes;")
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
tdLog.info("create database and stable") tdLog.info("create database and stable")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
threads=[] threads=[]
...@@ -234,7 +234,7 @@ class TDTestCase: ...@@ -234,7 +234,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping %s "%stopRole) tdLog.info("Take turns stopping %s "%stopRole)
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode": if stopRole == "mnode":
...@@ -242,7 +242,7 @@ class TDTestCase: ...@@ -242,7 +242,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -254,7 +254,7 @@ class TDTestCase: ...@@ -254,7 +254,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -265,12 +265,12 @@ class TDTestCase: ...@@ -265,12 +265,12 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
def run(self): def run(self):
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============") tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
self.createCluster() self.createCluster()
self.prepareData() self.prepareData()
......
...@@ -19,7 +19,7 @@ class TDTestCase: ...@@ -19,7 +19,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
## add for TD-6672 ## add for TD-6672
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), False)
def insertData(self, tb_name): def insertData(self, tb_name):
insert_sql_list = [f'insert into {tb_name} values ("2021-01-01 12:00:00", 1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1, 2, 3, 4)', insert_sql_list = [f'insert into {tb_name} values ("2021-01-01 12:00:00", 1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1, 2, 3, 4)',
...@@ -37,17 +37,17 @@ class TDTestCase: ...@@ -37,17 +37,17 @@ class TDTestCase:
for sql in insert_sql_list: for sql in insert_sql_list:
tdSql.execute(sql) tdSql.execute(sql)
def initTb(self): def initTb(self, dbname="db"):
tdCom.cleanTb() tdCom.cleanTb(dbname)
tb_name = tdCom.getLongName(8, "letters") tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
tdSql.execute( tdSql.execute(
f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned)") f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned)")
self.insertData(tb_name) self.insertData(tb_name)
return tb_name return tb_name
def initStb(self, count=5): def initStb(self, count=5, dbname="db"):
tdCom.cleanTb() tdCom.cleanTb(dbname)
tb_name = tdCom.getLongName(8, "letters") tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
tdSql.execute( tdSql.execute(
f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 tinyint unsigned, t11 smallint unsigned, t12 int unsigned, t13 bigint unsigned)") f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 tinyint unsigned, t11 smallint unsigned, t12 int unsigned, t13 bigint unsigned)")
for i in range(1, count+1): for i in range(1, count+1):
...@@ -56,9 +56,10 @@ class TDTestCase: ...@@ -56,9 +56,10 @@ class TDTestCase:
self.insertData(f'{tb_name}_sub_{i}') self.insertData(f'{tb_name}_sub_{i}')
return tb_name return tb_name
def initTwoStb(self): def initTwoStb(self, dbname="db"):
tdCom.cleanTb() tdCom.cleanTb(dbname)
tb_name = tdCom.getLongName(8, "letters") tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
# tb_name = tdCom.getLongName(8, "letters")
tb_name1 = f'{tb_name}1' tb_name1 = f'{tb_name}1'
tb_name2 = f'{tb_name}2' tb_name2 = f'{tb_name}2'
tdSql.execute( tdSql.execute(
......
此差异已折叠。
...@@ -120,16 +120,16 @@ class TDTestCase: ...@@ -120,16 +120,16 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): # sourcery skip: use-itertools-product def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname: for tb in tbname:
self.__rtrim_check(tb) self.__rtrim_check(tb)
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
def __test_error(self): def __test_error(self, dbname="db"):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname: for tb in tbname:
for errsql in self.__rtrim_err_check(tb): for errsql in self.__rtrim_err_check(tb):
...@@ -142,17 +142,15 @@ class TDTestCase: ...@@ -142,17 +142,15 @@ class TDTestCase:
self.__test_error() self.__test_error()
def __create_tb(self): def __create_tb(self, dbname="db"):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (t1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -162,29 +160,29 @@ class TDTestCase: ...@@ -162,29 +160,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
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} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname="db"):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -200,7 +198,7 @@ class TDTestCase: ...@@ -200,7 +198,7 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -216,13 +214,13 @@ class TDTestCase: ...@@ -216,13 +214,13 @@ class TDTestCase:
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -251,8 +249,7 @@ class TDTestCase: ...@@ -251,8 +249,7 @@ class TDTestCase:
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test()
tdDnodes.stop(1) tdSql.execute("flush database db")
tdDnodes.start(1)
tdSql.execute("use db") tdSql.execute("use db")
......
此差异已折叠。
此差异已折叠。
...@@ -30,14 +30,6 @@ class TDTestCase: ...@@ -30,14 +30,6 @@ class TDTestCase:
# updatecfgDict = {'debugFlag': 135} # updatecfgDict = {'debugFlag': 135}
# updatecfgDict = {'fqdn': 135} # updatecfgDict = {'fqdn': 135}
def caseDescription(self):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: offset return valid
'''
return
# init # init
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
...@@ -47,11 +39,12 @@ class TDTestCase: ...@@ -47,11 +39,12 @@ class TDTestCase:
self.ts = 1500000000000 self.ts = 1500000000000
# run case # run case
def run(self): def run(self):
# insert data # insert data
self.insert_data1("t1", self.ts, 1000*10000) dbname = "db"
self.insert_data1("t4", self.ts, 1000*10000) self.insert_data1(f"{dbname}.t1", self.ts, 1000*10000)
self.insert_data1(f"{dbname}.t4", self.ts, 1000*10000)
# test base case # test base case
# self.test_case1() # self.test_case1()
tdLog.debug(" LIMIT test_case1 ............ [OK]") tdLog.debug(" LIMIT test_case1 ............ [OK]")
...@@ -60,7 +53,7 @@ class TDTestCase: ...@@ -60,7 +53,7 @@ class TDTestCase:
tdLog.debug(" LIMIT test_case2 ............ [OK]") tdLog.debug(" LIMIT test_case2 ............ [OK]")
# stop # stop
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
...@@ -70,16 +63,16 @@ class TDTestCase: ...@@ -70,16 +63,16 @@ class TDTestCase:
# #
# create table # create table
def create_tables(self): def create_tables(self, dbname="db"):
# super table # super table
tdSql.execute("create table st(ts timestamp, i1 int,i2 int) tags(area int)"); tdSql.execute(f"create table {dbname}.st(ts timestamp, i1 int,i2 int) tags(area int)")
# child table # child table
tdSql.execute("create table t1 using st tags(1)"); tdSql.execute(f"create table {dbname}.t1 using {dbname}.st tags(1)")
tdSql.execute("create table st1(ts timestamp, i1 int ,i2 int) tags(area int) sma(i2) "); tdSql.execute(f"create table {dbname}.st1(ts timestamp, i1 int ,i2 int) tags(area int) sma(i2) ")
tdSql.execute("create table t4 using st1 tags(1)"); tdSql.execute(f"create table {dbname}.t4 using {dbname}.st1 tags(1)")
return return
# insert data1 # insert data1
def insert_data(self, tbname, ts_start, count): def insert_data(self, tbname, ts_start, count):
...@@ -91,7 +84,7 @@ class TDTestCase: ...@@ -91,7 +84,7 @@ class TDTestCase:
if i >0 and i%30000 == 0: if i >0 and i%30000 == 0:
tdSql.execute(sql) tdSql.execute(sql)
sql = pre_insert sql = pre_insert
# end sql # end sql
if sql != pre_insert: if sql != pre_insert:
tdSql.execute(sql) tdSql.execute(sql)
...@@ -107,16 +100,16 @@ class TDTestCase: ...@@ -107,16 +100,16 @@ class TDTestCase:
if i >0 and i%30000 == 0: if i >0 and i%30000 == 0:
tdSql.execute(sql) tdSql.execute(sql)
sql = pre_insert sql = pre_insert
# end sql # end sql
if sql != pre_insert: if sql != pre_insert:
tdSql.execute(sql) tdSql.execute(sql)
tdLog.debug("INSERT TABLE DATA ............ [OK]") tdLog.debug("INSERT TABLE DATA ............ [OK]")
return return
# test case1 base # test case1 base
# def test_case1(self): # def test_case1(self):
# # # #
# # limit base function # # limit base function
# # # #
# # base no where # # base no where
......
...@@ -20,7 +20,7 @@ class TDTestCase: ...@@ -20,7 +20,7 @@ class TDTestCase:
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file #tdSql.init(conn.cursor(), logSql) # output sql.txt file
def checkFileContent(self): def checkFileContent(self, dbname="sml_db"):
buildPath = tdCom.getBuildPath() buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/sml_test'%(buildPath) cmdStr = '%s/build/bin/sml_test'%(buildPath)
tdLog.info(cmdStr) tdLog.info(cmdStr)
...@@ -28,8 +28,8 @@ class TDTestCase: ...@@ -28,8 +28,8 @@ class TDTestCase:
if ret != 0: if ret != 0:
tdLog.exit("sml_test failed") tdLog.exit("sml_test failed")
tdSql.execute('use sml_db') # tdSql.execute('use sml_db')
tdSql.query("select * from t_b7d815c9222ca64cdf2614c61de8f211") tdSql.query(f"select * from {dbname}.t_b7d815c9222ca64cdf2614c61de8f211")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0, 0, '2016-01-01 08:00:07.000') tdSql.checkData(0, 0, '2016-01-01 08:00:07.000')
...@@ -44,35 +44,35 @@ class TDTestCase: ...@@ -44,35 +44,35 @@ class TDTestCase:
tdSql.checkData(0, 9, 0) tdSql.checkData(0, 9, 0)
tdSql.checkData(0, 10, 25) tdSql.checkData(0, 10, 25)
tdSql.query("select * from readings") tdSql.query(f"select * from {dbname}.readings")
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.query("select distinct tbname from readings") tdSql.query(f"select distinct tbname from {dbname}.readings")
tdSql.checkRows(4) tdSql.checkRows(4)
tdSql.query("select * from t_0799064f5487946e5d22164a822acfc8 order by _ts") tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 3, "kk") tdSql.checkData(0, 3, "kk")
tdSql.checkData(1, 3, None) tdSql.checkData(1, 3, None)
tdSql.query("select distinct tbname from `sys.if.bytes.out`") tdSql.query(f"select distinct tbname from {dbname}.`sys.if.bytes.out`")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select * from t_fc70dec6677d4277c5d9799c4da806da order by _ts") tdSql.query(f"select * from {dbname}.t_fc70dec6677d4277c5d9799c4da806da order by _ts")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 1, 1.300000000) tdSql.checkData(0, 1, 1.300000000)
tdSql.checkData(1, 1,13.000000000) tdSql.checkData(1, 1,13.000000000)
tdSql.query("select * from `sys.procs.running`") tdSql.query(f"select * from {dbname}.`sys.procs.running`")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0, 1, 42.000000000) tdSql.checkData(0, 1, 42.000000000)
tdSql.checkData(0, 2, "web01") tdSql.checkData(0, 2, "web01")
tdSql.query("select distinct tbname from `sys.cpu.nice`") tdSql.query(f"select distinct tbname from {dbname}.`sys.cpu.nice`")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select * from `sys.cpu.nice` order by _ts") tdSql.query(f"select * from {dbname}.`sys.cpu.nice` order by _ts")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 1, 9.000000000) tdSql.checkData(0, 1, 9.000000000)
tdSql.checkData(0, 2, "lga") tdSql.checkData(0, 2, "lga")
...@@ -83,10 +83,10 @@ class TDTestCase: ...@@ -83,10 +83,10 @@ class TDTestCase:
tdSql.checkData(1, 3, "web01") tdSql.checkData(1, 3, "web01")
tdSql.checkData(1, 4, "t1") tdSql.checkData(1, 4, "t1")
tdSql.query("select * from macylr") tdSql.query(f"select * from {dbname}.macylr")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("desc macylr") tdSql.query(f"desc {dbname}.macylr")
tdSql.checkRows(25) tdSql.checkRows(25)
return return
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -14,43 +14,44 @@ class TDTestCase: ...@@ -14,43 +14,44 @@ class TDTestCase:
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
dbname = "db"
tdSql.prepare() tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
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 varchar(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 varchar(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 varchar(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 varchar(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} )')
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}, 'varchar{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}, 'varchar{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}, 'varchar{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}, 'varchar{i}', 'nchar{i}', now()+{1*i}a )"
) )
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'varchar0', 'nchar0', now()+8a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'varchar0', 'nchar0', now()+8a )")
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'varchar9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'varchar9', '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, "varchar1", "nchar1", now()+1a ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "varchar1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "varchar2", "nchar2", now()+2a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "varchar2", "nchar2", now()+2a )
...@@ -70,7 +71,7 @@ class TDTestCase: ...@@ -70,7 +71,7 @@ class TDTestCase:
tdLog.printNoPrefix("==========step3: cast on varchar") tdLog.printNoPrefix("==========step3: cast on varchar")
tdSql.query("select c8 from ct1") tdSql.query(f"select c8 from {dbname}.ct1")
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
tdSql.checkData(i,0, data_ct1_c8[i]) tdSql.checkData(i,0, data_ct1_c8[i])
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册