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

Merge pull request #17725 from taosdata/test/TD-19911

teat: supplement  muti-branch for testcase histogram.py
......@@ -1651,7 +1651,7 @@ static int32_t translateMode(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
if (numOfParams == 0 || numOfParams > 2) {
if (numOfParams > 2) {
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
}
......
......@@ -134,7 +134,11 @@ class TDTestCase:
tdSql.query("create stream s1 into source_db.output_stb as select _wstart AS start, min(k), max(k), sum(k) from source_db.stb interval(10m);")
#TD-19944 -Q=3
tdsqlN=tdCom.newTdSql()
tdsqlN.query("select * from source_db.stb")
tdsqlN.query("select * from db0.stb")
def run(self):
# tdSql.prepare()
......@@ -164,6 +168,7 @@ class TDTestCase:
startAction = " -s -c " + taosdCfgPath
tdLog.printNoPrefix("================================ parameter: %s"%startAction)
self.taosdCommandExe(startAction,taosdCmdRun)
os.system(" rm -rf sdb.json ")
startAction = " --help"
......@@ -198,7 +203,7 @@ class TDTestCase:
startAction=" -E taosdCaseTmp/.env"
tdLog.printNoPrefix("================================ parameter: %s"%startAction)
os.system(" mkdir -p taosdCaseTmp/.env ")
os.system(" mkdir -p taosdCaseTmp ")
os.system("echo \'TAOS_QUERY_POLICY=3\' > taosdCaseTmp/.env ")
self.taosdCommandStop(startAction,taosdCmdRun)
os.system(" rm -rf taosdCaseTmp/.env ")
......
......@@ -184,6 +184,7 @@ class TDTestCase:
tdSql.query("select count(*) from hn_table_1_r;")
tdSql.checkData(0,0,num_random*n)
sleep(5)
# stream data check
tdSql.query("select start,wend,max_int from stream_max_stable_1 ;")
tdSql.checkRows(20)
......
......@@ -93,8 +93,19 @@ class TDTestCase:
tdSql.error(f"select diff(col12) from {dbname}.stb_1")
tdSql.error(f"select diff(col13) from {dbname}.stb_1")
tdSql.error(f"select diff(col14) from {dbname}.stb_1")
tdSql.error(f"select diff(col14) from {dbname}.stb_1")
tdSql.error(f"select diff(col1,col1,col1) from {dbname}.stb_1")
tdSql.error(f"select diff(col1,1,col1) from {dbname}.stb_1")
tdSql.error(f"select diff(col1,col1,col) from {dbname}.stb_1")
tdSql.error(f"select diff(col1,col1) from {dbname}.stb_1")
tdSql.error(f"select diff(col1,'123') from {dbname}.stb_1")
tdSql.error(f"select diff(col1,1.23) from {dbname}.stb_1")
tdSql.error(f"select diff(col1,-1) from {dbname}.stb_1")
tdSql.query(f"select ts,diff(col1),ts from {dbname}.stb_1")
tdSql.query(f"select diff(ts) from {dbname}.stb_1")
tdSql.checkRows(10)
tdSql.query(f"select diff(col1) from {dbname}.stb_1")
tdSql.checkRows(10)
......
......@@ -86,13 +86,20 @@ class TDTestCase:
'''
return
def prepare_data(self):
def prepare_db(self,dbname,vgroupVar):
tdLog.info (" ====================================== prepare db ==================================================")
tdSql.execute('drop database if exists testdb ;')
tdSql.execute('create database %s keep 36500 vgroups %d ;'%(dbname,vgroupVar))
def prepare_data(self,dbname):
tdLog.info (" ====================================== prepare data ==================================================")
tdSql.execute('drop database if exists testdb ;')
tdSql.execute('create database testdb keep 36500;')
tdSql.execute('use testdb;')
# tdSql.execute('drop database if exists testdb ;')
# tdSql.execute('create database testdb keep 36500;')
tdSql.execute('use %s;'%dbname)
tdSql.execute('create stable stable_1(ts timestamp ,tscol timestamp, q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, q_float float ,\
q_double double , bin_chars binary(20)) tags(loc nchar(20) ,ind int,tstag timestamp);')
......@@ -1305,17 +1312,26 @@ class TDTestCase:
# ts can't be used at outer query
tdSql.query("select elapsed(ts,1s) from (select ts from regular_table_1 );")
tdSql.query("select elapsed(ts,1s) from (select ts from stable_1 );")
# case : TD-12164
tdSql.error("select elapsed(ts,1s) from (select qint ts from regular_table_1 );")
tdSql.error("select elapsed(tbname ,1s) from (select qint tbname from regular_table_1 );")
tdSql.error("select elapsed(tsc ,1s) from (select q_int tsc from regular_table_1) ;")
tdSql.error("select elapsed(tsv ,1s) from (select elapsed(ts,1s) tsv from regular_table_1);")
tdSql.error("select elapsed(ts ,1s) from (select elapsed(ts,1s) ts from regular_table_1);")
tdSql.error("select elapsed(ts,1s) from (select qint ts from stable_1 );")
tdSql.error("select elapsed(tbname ,1s) from (select qint tbname from stable_1 );")
tdSql.error("select elapsed(tsc ,1s) from (select q_int tsc from stable_1) ;")
tdSql.error("select elapsed(tsv ,1s) from (select elapsed(ts,1s) tsv from stable_1);")
tdSql.error("select elapsed(ts ,1s) from (select elapsed(ts,1s) ts from stable_1);")
# # bug fix
tdSql.error("select elapsed(tsc ,1s) from (select tscol tsc from regular_table_1) ;")
tdSql.error("select elapsed(tsc ,1s) from (select tscol tsc from stable_1) ;")
#TD-19911
tdSql.error("select elapsed(ts,1s,123) from (select ts,tbname from stable_1 order by ts asc );")
tdSql.error("select elapsed() from (select ts,tbname from stable_1 order by ts asc );")
tdSql.error("select elapsed(tscol,1s) from (select ts,tbname from stable_1 order by ts asc );")
tdSql.error("select elapsed(ts,1n) from (select ts,tbname from stable_1 order by ts asc );")
tdSql.error("select elapsed(ts,1y) from (select ts,tbname from stable_1 order by ts asc );")
tdSql.error("select elapsed(ts,tscol) from (select ts,tbname from stable_1 order by ts asc );")
tdSql.error("select elapsed(bin_chars,tscol) from (select ts,tbname from stable_1 order by ts asc );")
# case TD-12276
tdSql.query("select elapsed(ts,1s) from (select ts,tbname from regular_table_1 order by ts asc );")
......@@ -1525,7 +1541,6 @@ class TDTestCase:
def query_precision(self):
def generate_data(precision="ms"):
tdSql.execute("create database if not exists db_%s precision '%s';" %(precision, precision))
tdSql.execute("use db_%s;" %precision)
tdSql.execute("create stable db_%s.st (ts timestamp , id int) tags(ind int);"%precision)
......@@ -1579,7 +1594,9 @@ class TDTestCase:
def run(self):
tdSql.prepare()
self.prepare_data()
dbNameTest="testdbV1"
self.prepare_db(dbNameTest,1)
self.prepare_data(dbNameTest)
self.abnormal_common_test()
self.abnormal_use_test()
self.query_filter()
......@@ -1596,6 +1613,25 @@ class TDTestCase:
self.continuous_query()
self.query_precision()
dbNameTest="testdbV2"
self.prepare_db(dbNameTest,2)
self.prepare_data(dbNameTest)
self.abnormal_common_test()
self.abnormal_use_test()
self.query_filter()
# self.query_interval()
self.query_mix_common()
self.query_mix_Aggregate()
self.query_mix_select()
self.query_mix_compute()
self.query_mix_arithmetic()
# self.query_with_join()
# self.query_with_union()
self.query_nest()
self.query_session_windows()
self.continuous_query()
# self.query_precision()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
......
......@@ -48,10 +48,12 @@ DBNAME = "db"
STBNAME = "stb1"
CTBNAME = "ct1"
NTBNAME = "nt1"
PARAINF = float("inf")
@dataclass
class Hsgschema:
func_type : str = "SELECT"
from_clause : str = f"{STBNAME}"
where_clause : str = None
......@@ -269,7 +271,7 @@ class TDTestCase:
else:
tdLog.success(f"summary of result count is {sum_rate}!")
else:
def hsg_check_error(self, sma:Hsgschema, dbname=DBNAME):
tdSql.error(self.__gen_sql(sma, dbname))
@property
......@@ -319,6 +321,7 @@ class TDTestCase:
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 1, "width": 1, "count": -10, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 1, "width": 1, "count": 10, "infinity": "false"}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 1, "width": 1, "count": 10, "infinity": null}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin=['{"start": 1, "factor": 4, "count": 4, "infinity": true}'], normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='[{"start": 1, "factor": 4, "count": 4, "infinity": true}]', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"begin": 1, "factor": 4, "count": 4, "infinity": true}', normalized=1 ) )
......@@ -347,6 +350,51 @@ class TDTestCase:
err_sqls.append( Hsgschema( col=BOOL_COL, bin_type="log_bin", log_bin='{"start": 1, "factor": 10, "count": 10, "infinity": false}') )
# add testcase by chr
err_sqls.append( Hsgschema( col=INT_COL, bin_type="USER_INPUT", user_input="[]", normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="USER_INPUT", user_input="[1,'listStr',2]", normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": %f, "width": 10000000, "count": 10000000, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 2000, "width": %f, "count": 10, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 10, "width": 10, "count": %f, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor": %f, "count": 10, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": %f, "width": %f, "count": %f, "infinity": false}'%(PARAINF,PARAINF,PARAINF), normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 10, "width": 10, "count": 0, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 10, "width": 10, "count": -10, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 10, "width": 10, "count": 1001, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="linear_bin", linear_bin='{"start": 10, "width": 10, "count": 1001, "infinity": false , "linerBinNumber":5}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor":-100, "count": 10, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor":0, "count": 10, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor":1, "count": 10, "infinity": false}', normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": %f, "factor":10, "count": 10, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor":10, "count": %f, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor":10, "count": %f, "infinity": false}'%PARAINF, normalized=1 ) )
err_sqls.append( Hsgschema( col=INT_COL, bin_type="log_bin", log_bin='{"start": 1, "factor":10, "count": %f, "infinity": false, "logBinNumber":5}', normalized=1 ) )
err_sqls.append( Hsgschema(col={"errorColType": INT_COL}, bin_type="USER_INPUT", user_input="[0,3,6,9]", normalized=1) )
# err_sqls.append( Hsgschema(col=INT_COL, bin_type=, user_input="[0,3,6,9]", normalized=1) )
# err_sqls.append( Hsgschema(col=INT_COL, bin_type="USER_INPUT", user_input="[0,3,6,9]", normalized=1) )
# err_sqls.append( Hsgschema(col=INT_COL, bin_type="USER_INPUT", user_input="[0,3,6,9]", normalized=1) )
### case 2:
# current_set
......@@ -386,7 +434,7 @@ class TDTestCase:
def test_histogram(self, dbname=DBNAME, ctb_num :int=20):
err_sqls , cur_sqls = self.__hsg_querysql
for err_sql in err_sqls:
self.hsg_check(err_sql, dbname)
self.hsg_check_error(err_sql, dbname)
for cur_sql in cur_sqls:
self.hsg_check(cur_sql, dbname)
......@@ -405,6 +453,29 @@ class TDTestCase:
tdSql.checkData(1, 0, '{"lower_bin":3, "upper_bin":6, "count":3}')
tdSql.checkData(2, 0, '{"lower_bin":6, "upper_bin":9, "count":3}')
# if (4 != numOfParams)
# tdSql.error("select HISTOGRAM(c_int, \"linear_bin\", \"{\"start\": -200, \"width\": 100, \"count\": 20, \"infinity\": false}\", 1 , InvalidNumber) from db.stb1 where c_int < 10")
tdSql.error('SELECT HISTOGRAM(c_int, "linear_bin", \'{"start": -200, "width": 100, "count": 20, "infinity": false}\', 0 ,InvalidNumber ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "linear_bin", \'{"start": -200, "width": 100, "count": 20, "infinity": false}\' ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, 54321, "[0,3,6,9]", 1 ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "USER_INPUT", 54321, 0 ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "USER_INPUT", "[0,3,6,9]", InvalidNumber ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "USER_INPUT", "[0,3,6,9]", -100 ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, c_int, "[0,3,6,9]", 1 ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "USER_INPUT", c_int, 1 ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "USER_INPUT", "[0,3,6,9]", c_int ) from %s.stb1'%dbname)
tdSql.query('SELECT HISTOGRAM(123, "USER_INPUT", "[0,3,6,9]", 0 ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM(c_binary, "USER_INPUT", "[0,3,6,9]", 0 ) from %s.stb1'%dbname)
tdSql.error('SELECT HISTOGRAM("c_binary", "USER_INPUT", "[0,3,6,9]", 0 ) from %s.stb1'%dbname)
tdSql.query('SELECT HISTOGRAM(123, "linear_bin", \'{"start": 1, "width": 10, "count": 20, "infinity": false}\',0 ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_binary, "linear_bin", \'{"start": 1, "width": 10, "count": 20, "infinity": false}\',0 ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM("c_binary", "linear_bin", \'{"start": 1, "width": 10, "count": 20, "infinity": false}\',0 ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "c_int", \'{"start": 1, "width": 10, "count": 20, "infinity": false}\',0 ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "linear_bin", c_int,0 ) from %s.stb1 '%dbname)
tdSql.error('SELECT HISTOGRAM(c_int, "linear_bin", \'{"start": 1, "width": 10, "count": 20, "infinity": false}\',c_int ) from %s.stb1 '%dbname)
def all_test(self, dbname=DBNAME):
self.test_histogram(dbname)
......
......@@ -437,6 +437,10 @@ class TDTestCase:
tdSql.checkData(0,0,4)
tdSql.checkData(1,0,1)
# TD-19911
tdSql.error("select unique(mode(12)) from (select _rowts , t1 , tbname from db.stb1 );")
tdSql.error("select unique(mode(t1,1)) from (select _rowts , t1 , tbname from db.stb1 );")
def check_boundary_values(self, dbname="bound_test"):
tdSql.execute(f"drop database if exists {dbname}")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册