fix case
This commit is contained in:
parent
09982db5d3
commit
3a5f3203a0
|
@ -199,22 +199,22 @@ class TDCom:
|
|||
res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0])
|
||||
return res
|
||||
|
||||
def cleanTb(self, type="taosc"):
|
||||
def cleanTb(self, type="taosc", dbname="db"):
|
||||
'''
|
||||
type is taosc or restful
|
||||
'''
|
||||
query_sql = "show stables"
|
||||
query_sql = f"show {dbname}.stables"
|
||||
res_row_list = tdSql.query(query_sql, True)
|
||||
stb_list = map(lambda x: x[0], res_row_list)
|
||||
for stb in stb_list:
|
||||
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():
|
||||
tdSql.execute(f'drop table if exists {stb}')
|
||||
tdSql.execute(f'drop table if exists {dbname}.{stb}')
|
||||
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():
|
||||
self.restApiPost(f"drop table if exists {stb}")
|
||||
self.restApiPost(f"drop table if exists {dbname}.{stb}")
|
||||
|
||||
def dateToTs(self, datetime_input):
|
||||
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
|
||||
|
|
|
@ -13,9 +13,9 @@ from util.common import *
|
|||
|
||||
sys.path.append("./6-cluster/")
|
||||
from clusterCommonCreate import *
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
|
||||
import threading
|
||||
import threading
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TDTestCase:
|
|||
|
||||
def init(self, conn, logSql):
|
||||
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):
|
||||
tsql.execute("use %s" %dbName)
|
||||
|
@ -47,7 +47,7 @@ class TDTestCase:
|
|||
sql = pre_create
|
||||
if sql != pre_create:
|
||||
tsql.execute(sql)
|
||||
|
||||
|
||||
tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName))
|
||||
return
|
||||
|
||||
|
@ -55,7 +55,7 @@ class TDTestCase:
|
|||
dbname="db_tsbs"
|
||||
stabname1="readings"
|
||||
stabname2="diagnostics"
|
||||
ctbnamePre1="rct"
|
||||
ctbnamePre1="rct"
|
||||
ctbnamePre2="dct"
|
||||
ctbNums=40
|
||||
self.ctbNums=ctbNums
|
||||
|
@ -73,7 +73,7 @@ class TDTestCase:
|
|||
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):
|
||||
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} )"
|
||||
|
@ -109,19 +109,19 @@ class TDTestCase:
|
|||
|
||||
def tsbsIotQuery(self,tdSql):
|
||||
tdSql.execute("use db_tsbs")
|
||||
|
||||
|
||||
# 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; ")
|
||||
# print(tdSql.queryResult)
|
||||
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.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.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);")
|
||||
|
||||
|
||||
|
@ -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 ;")
|
||||
|
||||
# 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) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name")
|
||||
|
||||
|
@ -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) ;")
|
||||
|
||||
|
||||
# # 6. avg-daily-driving-session
|
||||
# # 6. avg-daily-driving-session
|
||||
# #taosc core dumped
|
||||
# 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;")
|
||||
|
@ -166,7 +166,7 @@ class TDTestCase:
|
|||
# 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 ;")
|
||||
|
||||
# 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) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;")
|
||||
|
@ -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 ;")
|
||||
|
||||
|
||||
#it's already supported:
|
||||
# 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 ;")
|
||||
|
@ -192,7 +192,7 @@ class TDTestCase:
|
|||
|
||||
#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;")
|
||||
|
||||
|
||||
# 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")
|
||||
|
||||
|
@ -213,16 +213,16 @@ class TDTestCase:
|
|||
'ctbPrefix': 'ctb',
|
||||
'ctbNum': 1,
|
||||
}
|
||||
|
||||
|
||||
dnodeNumbers=int(dnodeNumbers)
|
||||
mnodeNums=int(mnodeNums)
|
||||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
|
||||
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||
|
||||
tdLog.info("create database and stable")
|
||||
tdLog.info("create database and stable")
|
||||
tdDnodes=cluster.dnodes
|
||||
stopcount =0
|
||||
threads=[]
|
||||
|
@ -234,7 +234,7 @@ class TDTestCase:
|
|||
for tr in threads:
|
||||
tr.start()
|
||||
|
||||
tdLog.info("Take turns stopping %s "%stopRole)
|
||||
tdLog.info("Take turns stopping %s "%stopRole)
|
||||
while stopcount < restartNumbers:
|
||||
tdLog.info(" restart loop: %d"%stopcount )
|
||||
if stopRole == "mnode":
|
||||
|
@ -242,7 +242,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
elif stopRole == "vnode":
|
||||
for i in range(vnodeNumbers):
|
||||
tdDnodes[i+mnodeNums].stoptaosd()
|
||||
|
@ -254,7 +254,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
|
||||
# dnodeNumbers don't include database of schema
|
||||
if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||
|
@ -265,12 +265,12 @@ class TDTestCase:
|
|||
tdLog.exit("one or more of dnodes failed to start ")
|
||||
# self.check3mnode()
|
||||
stopcount+=1
|
||||
|
||||
|
||||
for tr in threads:
|
||||
tr.join()
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
|
||||
self.createCluster()
|
||||
self.prepareData()
|
||||
|
|
|
@ -19,7 +19,7 @@ class TDTestCase:
|
|||
def init(self, conn, logSql):
|
||||
## add for TD-6672
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
|
||||
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)',
|
||||
|
@ -37,17 +37,17 @@ class TDTestCase:
|
|||
for sql in insert_sql_list:
|
||||
tdSql.execute(sql)
|
||||
|
||||
def initTb(self):
|
||||
tdCom.cleanTb()
|
||||
tb_name = tdCom.getLongName(8, "letters")
|
||||
def initTb(self, dbname="db"):
|
||||
tdCom.cleanTb(dbname)
|
||||
tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
|
||||
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)")
|
||||
self.insertData(tb_name)
|
||||
return tb_name
|
||||
|
||||
def initStb(self, count=5):
|
||||
tdCom.cleanTb()
|
||||
tb_name = tdCom.getLongName(8, "letters")
|
||||
def initStb(self, count=5, dbname="db"):
|
||||
tdCom.cleanTb(dbname)
|
||||
tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
|
||||
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)")
|
||||
for i in range(1, count+1):
|
||||
|
@ -56,9 +56,10 @@ class TDTestCase:
|
|||
self.insertData(f'{tb_name}_sub_{i}')
|
||||
return tb_name
|
||||
|
||||
def initTwoStb(self):
|
||||
tdCom.cleanTb()
|
||||
tb_name = tdCom.getLongName(8, "letters")
|
||||
def initTwoStb(self, dbname="db"):
|
||||
tdCom.cleanTb(dbname)
|
||||
tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
|
||||
# tb_name = tdCom.getLongName(8, "letters")
|
||||
tb_name1 = f'{tb_name}1'
|
||||
tb_name2 = f'{tb_name}2'
|
||||
tdSql.execute(
|
||||
|
|
|
@ -8,49 +8,46 @@ from util.sql import *
|
|||
from util.cases import *
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def prepare_datas(self):
|
||||
def prepare_datas(self, dbname="db"):
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -94,68 +91,68 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.info("round value check pass , it work as expected ,sql is \"%s\" "%round_query )
|
||||
|
||||
def test_errors(self):
|
||||
def test_errors(self, dbname="db"):
|
||||
error_sql_lists = [
|
||||
"select round from t1",
|
||||
# "select round(-+--+c1) from t1",
|
||||
# "select +-round(c1) from t1",
|
||||
# "select ++-round(c1) from t1",
|
||||
# "select ++--round(c1) from t1",
|
||||
# "select - -round(c1)*0 from t1",
|
||||
# "select round(tbname+1) from t1 ",
|
||||
"select round(123--123)==1 from t1",
|
||||
"select round(c1) as 'd1' from t1",
|
||||
"select round(c1 ,c2 ) from t1",
|
||||
"select round(c1 ,NULL) from t1",
|
||||
"select round(,) from t1;",
|
||||
"select round(round(c1) ab from t1)",
|
||||
"select round(c1) as int from t1",
|
||||
"select round from stb1",
|
||||
# "select round(-+--+c1) from stb1",
|
||||
# "select +-round(c1) from stb1",
|
||||
# "select ++-round(c1) from stb1",
|
||||
# "select ++--round(c1) from stb1",
|
||||
# "select - -round(c1)*0 from stb1",
|
||||
# "select round(tbname+1) from stb1 ",
|
||||
"select round(123--123)==1 from stb1",
|
||||
"select round(c1) as 'd1' from stb1",
|
||||
"select round(c1 ,c2 ) from stb1",
|
||||
"select round(c1 ,NULL) from stb1",
|
||||
"select round(,) from stb1;",
|
||||
"select round(round(c1) ab from stb1)",
|
||||
"select round(c1) as int from stb1"
|
||||
f"select round from {dbname}.t1",
|
||||
# f"select round(-+--+c1) from {dbname}.t1",
|
||||
# f"select +-round(c1) from {dbname}.t1",
|
||||
# f"select ++-round(c1) from {dbname}.t1",
|
||||
# f"select ++--round(c1) from {dbname}.t1",
|
||||
# f"select - -round(c1)*0 from {dbname}.t1",
|
||||
# f"select round(tbname+1) from {dbname}.t1 ",
|
||||
f"select round(123--123)==1 from {dbname}.t1",
|
||||
f"select round(c1) as 'd1' from {dbname}.t1",
|
||||
f"select round(c1 ,c2 ) from {dbname}.t1",
|
||||
f"select round(c1 ,NULL) from {dbname}.t1",
|
||||
f"select round(,) from {dbname}.t1;",
|
||||
f"select round(round(c1) ab from {dbname}.t1)",
|
||||
f"select round(c1) as int from {dbname}.t1",
|
||||
f"select round from {dbname}.stb1",
|
||||
# f"select round(-+--+c1) from {dbname}.stb1",
|
||||
# f"select +-round(c1) from {dbname}.stb1",
|
||||
# f"select ++-round(c1) from {dbname}.stb1",
|
||||
# f"select ++--round(c1) from {dbname}.stb1",
|
||||
# f"select - -round(c1)*0 from {dbname}.stb1",
|
||||
# f"select round(tbname+1) from {dbname}.stb1 ",
|
||||
f"select round(123--123)==1 from {dbname}.stb1",
|
||||
f"select round(c1) as 'd1' from {dbname}.stb1",
|
||||
f"select round(c1 ,c2 ) from {dbname}.stb1",
|
||||
f"select round(c1 ,NULL) from {dbname}.stb1",
|
||||
f"select round(,) from {dbname}.stb1;",
|
||||
f"select round(round(c1) ab from {dbname}.stb1)",
|
||||
f"select round(c1) as int from {dbname}.stb1"
|
||||
]
|
||||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
def support_types(self):
|
||||
def support_types(self, dbname="db"):
|
||||
type_error_sql_lists = [
|
||||
"select round(ts) from t1" ,
|
||||
"select round(c7) from t1",
|
||||
"select round(c8) from t1",
|
||||
"select round(c9) from t1",
|
||||
"select round(ts) from ct1" ,
|
||||
"select round(c7) from ct1",
|
||||
"select round(c8) from ct1",
|
||||
"select round(c9) from ct1",
|
||||
"select round(ts) from ct3" ,
|
||||
"select round(c7) from ct3",
|
||||
"select round(c8) from ct3",
|
||||
"select round(c9) from ct3",
|
||||
"select round(ts) from ct4" ,
|
||||
"select round(c7) from ct4",
|
||||
"select round(c8) from ct4",
|
||||
"select round(c9) from ct4",
|
||||
"select round(ts) from stb1" ,
|
||||
"select round(c7) from stb1",
|
||||
"select round(c8) from stb1",
|
||||
"select round(c9) from stb1" ,
|
||||
f"select round(ts) from {dbname}.t1" ,
|
||||
f"select round(c7) from {dbname}.t1",
|
||||
f"select round(c8) from {dbname}.t1",
|
||||
f"select round(c9) from {dbname}.t1",
|
||||
f"select round(ts) from {dbname}.ct1" ,
|
||||
f"select round(c7) from {dbname}.ct1",
|
||||
f"select round(c8) from {dbname}.ct1",
|
||||
f"select round(c9) from {dbname}.ct1",
|
||||
f"select round(ts) from {dbname}.ct3" ,
|
||||
f"select round(c7) from {dbname}.ct3",
|
||||
f"select round(c8) from {dbname}.ct3",
|
||||
f"select round(c9) from {dbname}.ct3",
|
||||
f"select round(ts) from {dbname}.ct4" ,
|
||||
f"select round(c7) from {dbname}.ct4",
|
||||
f"select round(c8) from {dbname}.ct4",
|
||||
f"select round(c9) from {dbname}.ct4",
|
||||
f"select round(ts) from {dbname}.stb1" ,
|
||||
f"select round(c7) from {dbname}.stb1",
|
||||
f"select round(c8) from {dbname}.stb1",
|
||||
f"select round(c9) from {dbname}.stb1" ,
|
||||
|
||||
"select round(ts) from stbbb1" ,
|
||||
"select round(c7) from stbbb1",
|
||||
f"select round(ts) from {dbname}.stbbb1" ,
|
||||
f"select round(c7) from {dbname}.stbbb1",
|
||||
|
||||
"select round(ts) from tbname",
|
||||
"select round(c9) from tbname"
|
||||
f"select round(ts) from {dbname}.tbname",
|
||||
f"select round(c9) from {dbname}.tbname"
|
||||
|
||||
]
|
||||
|
||||
|
@ -164,127 +161,127 @@ class TDTestCase:
|
|||
|
||||
|
||||
type_sql_lists = [
|
||||
"select round(c1) from t1",
|
||||
"select round(c2) from t1",
|
||||
"select round(c3) from t1",
|
||||
"select round(c4) from t1",
|
||||
"select round(c5) from t1",
|
||||
"select round(c6) from t1",
|
||||
f"select round(c1) from {dbname}.t1",
|
||||
f"select round(c2) from {dbname}.t1",
|
||||
f"select round(c3) from {dbname}.t1",
|
||||
f"select round(c4) from {dbname}.t1",
|
||||
f"select round(c5) from {dbname}.t1",
|
||||
f"select round(c6) from {dbname}.t1",
|
||||
|
||||
"select round(c1) from ct1",
|
||||
"select round(c2) from ct1",
|
||||
"select round(c3) from ct1",
|
||||
"select round(c4) from ct1",
|
||||
"select round(c5) from ct1",
|
||||
"select round(c6) from ct1",
|
||||
f"select round(c1) from {dbname}.ct1",
|
||||
f"select round(c2) from {dbname}.ct1",
|
||||
f"select round(c3) from {dbname}.ct1",
|
||||
f"select round(c4) from {dbname}.ct1",
|
||||
f"select round(c5) from {dbname}.ct1",
|
||||
f"select round(c6) from {dbname}.ct1",
|
||||
|
||||
"select round(c1) from ct3",
|
||||
"select round(c2) from ct3",
|
||||
"select round(c3) from ct3",
|
||||
"select round(c4) from ct3",
|
||||
"select round(c5) from ct3",
|
||||
"select round(c6) from ct3",
|
||||
f"select round(c1) from {dbname}.ct3",
|
||||
f"select round(c2) from {dbname}.ct3",
|
||||
f"select round(c3) from {dbname}.ct3",
|
||||
f"select round(c4) from {dbname}.ct3",
|
||||
f"select round(c5) from {dbname}.ct3",
|
||||
f"select round(c6) from {dbname}.ct3",
|
||||
|
||||
"select round(c1) from stb1",
|
||||
"select round(c2) from stb1",
|
||||
"select round(c3) from stb1",
|
||||
"select round(c4) from stb1",
|
||||
"select round(c5) from stb1",
|
||||
"select round(c6) from stb1",
|
||||
f"select round(c1) from {dbname}.stb1",
|
||||
f"select round(c2) from {dbname}.stb1",
|
||||
f"select round(c3) from {dbname}.stb1",
|
||||
f"select round(c4) from {dbname}.stb1",
|
||||
f"select round(c5) from {dbname}.stb1",
|
||||
f"select round(c6) from {dbname}.stb1",
|
||||
|
||||
"select round(c6) as alisb from stb1",
|
||||
"select round(c6) alisb from stb1",
|
||||
f"select round(c6) as alisb from {dbname}.stb1",
|
||||
f"select round(c6) alisb from {dbname}.stb1",
|
||||
]
|
||||
|
||||
for type_sql in type_sql_lists:
|
||||
tdSql.query(type_sql)
|
||||
|
||||
def basic_round_function(self):
|
||||
def basic_round_function(self, dbname="db"):
|
||||
|
||||
# basic query
|
||||
tdSql.query("select c1 from ct3")
|
||||
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select c1 from t1")
|
||||
tdSql.query(f"select c1 from {dbname}.t1")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select c1 from stb1")
|
||||
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
# used for empty table , ct3 is empty
|
||||
tdSql.query("select round(c1) from ct3")
|
||||
tdSql.query(f"select round(c1) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c2) from ct3")
|
||||
tdSql.query(f"select round(c2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c3) from ct3")
|
||||
tdSql.query(f"select round(c3) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c4) from ct3")
|
||||
tdSql.query(f"select round(c4) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c5) from ct3")
|
||||
tdSql.query(f"select round(c5) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c6) from ct3")
|
||||
tdSql.query(f"select round(c6) from {dbname}.ct3")
|
||||
|
||||
# used for regular table
|
||||
tdSql.query("select round(c1) from t1")
|
||||
tdSql.query(f"select round(c1) from {dbname}.t1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1 , 0, 1)
|
||||
tdSql.checkData(3 , 0, 3)
|
||||
tdSql.checkData(5 , 0, None)
|
||||
|
||||
tdSql.query("select c1, c2, c3 , c4, c5 from t1")
|
||||
tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||
tdSql.checkData(1, 4, 1.11000)
|
||||
tdSql.checkData(3, 3, 33)
|
||||
tdSql.checkData(5, 4, None)
|
||||
tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1")
|
||||
tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||
tdSql.checkData(1, 5, 1.11000)
|
||||
tdSql.checkData(3, 4, 33)
|
||||
tdSql.checkData(5, 5, None)
|
||||
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 from t1", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from t1")
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.t1")
|
||||
|
||||
# used for sub table
|
||||
tdSql.query("select round(c1) from ct1")
|
||||
tdSql.query(f"select round(c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(1 , 0, 7)
|
||||
tdSql.checkData(3 , 0, 5)
|
||||
tdSql.checkData(5 , 0, 4)
|
||||
|
||||
tdSql.query("select round(c1) from ct1")
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct1", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from ct1")
|
||||
self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from ct1;","select c1 from ct1" )
|
||||
tdSql.query(f"select round(c1) from {dbname}.ct1")
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.ct1")
|
||||
self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.ct1;",f"select c1 from {dbname}.ct1" )
|
||||
|
||||
# used for stable table
|
||||
|
||||
tdSql.query("select round(c1) from stb1")
|
||||
tdSql.query(f"select round(c1) from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct4 ", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from ct4")
|
||||
self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from ct4;" , "select c1 from ct4" )
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.ct4 ", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.ct4")
|
||||
self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.ct4;" , f"select c1 from {dbname}.ct4" )
|
||||
|
||||
|
||||
# used for not exists table
|
||||
tdSql.error("select round(c1) from stbbb1")
|
||||
tdSql.error("select round(c1) from tbname")
|
||||
tdSql.error("select round(c1) from ct5")
|
||||
tdSql.error(f"select round(c1) from {dbname}.stbbb1")
|
||||
tdSql.error(f"select round(c1) from {dbname}.tbname")
|
||||
tdSql.error(f"select round(c1) from {dbname}.ct5")
|
||||
|
||||
# mix with common col
|
||||
tdSql.query("select c1, round(c1) from ct1")
|
||||
tdSql.query(f"select c1, round(c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0 , 0 ,8)
|
||||
tdSql.checkData(0 , 1 ,8)
|
||||
tdSql.checkData(4 , 0 ,0)
|
||||
tdSql.checkData(4 , 1 ,0)
|
||||
tdSql.query("select c1, round(c1) from ct4")
|
||||
tdSql.query(f"select c1, round(c1) from {dbname}.ct4")
|
||||
tdSql.checkData(0 , 0 , None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(4 , 0 ,5)
|
||||
tdSql.checkData(4 , 1 ,5)
|
||||
tdSql.checkData(5 , 0 ,None)
|
||||
tdSql.checkData(5 , 1 ,None)
|
||||
tdSql.query("select c1, round(c1) from ct4 ")
|
||||
tdSql.query(f"select c1, round(c1) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0 , 0 ,None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(4 , 0 ,5)
|
||||
tdSql.checkData(4 , 1 ,5)
|
||||
|
||||
# mix with common functions
|
||||
tdSql.query("select c1, round(c1),c5, round(c5) from ct4 ")
|
||||
tdSql.query(f"select c1, round(c1),c5, round(c5) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0 , 0 ,None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(0 , 2 ,None)
|
||||
|
@ -300,34 +297,34 @@ class TDTestCase:
|
|||
tdSql.checkData(6 , 2 ,4.44000)
|
||||
tdSql.checkData(6 , 3 ,4.00000)
|
||||
|
||||
tdSql.query("select c1, round(c1),c5, round(c5) from stb1 ")
|
||||
tdSql.query(f"select c1, round(c1),c5, round(c5) from {dbname}.stb1 ")
|
||||
|
||||
# mix with agg functions , not support
|
||||
tdSql.error("select c1, round(c1),c5, count(c5) from stb1 ")
|
||||
tdSql.error("select c1, round(c1),c5, count(c5) from ct1 ")
|
||||
tdSql.error("select round(c1), count(c5) from stb1 ")
|
||||
tdSql.error("select round(c1), count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from stb1 ")
|
||||
tdSql.error(f"select c1, round(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1, round(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select round(c1), count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select round(c1), count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||
|
||||
# agg functions mix with agg functions
|
||||
|
||||
tdSql.query("select max(c5), count(c5) from stb1")
|
||||
tdSql.query("select max(c5), count(c5) from ct1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||
|
||||
|
||||
# bug fix for count
|
||||
tdSql.query("select count(c1) from ct4 ")
|
||||
tdSql.query(f"select count(c1) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0,0,9)
|
||||
tdSql.query("select count(*) from ct4 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0,0,12)
|
||||
tdSql.query("select count(c1) from stb1 ")
|
||||
tdSql.query(f"select count(c1) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0,0,22)
|
||||
tdSql.query("select count(*) from stb1 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0,0,25)
|
||||
|
||||
# bug fix for compute
|
||||
tdSql.query("select c1, abs(c1) -0 ,round(c1)-0 from ct4 ")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,round(c1)-0 from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -335,7 +332,7 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 8.000000000)
|
||||
|
||||
tdSql.query(" select c1, abs(c1) -0 ,round(c1-0.1)-0.1 from ct4")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,round(c1-0.1)-0.1 from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -343,9 +340,8 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 7.900000000)
|
||||
|
||||
def abs_func_filter(self):
|
||||
tdSql.execute("use db")
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>5 ")
|
||||
def abs_func_filter(self, dbname="db"):
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,8.000000000)
|
||||
|
@ -353,7 +349,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,7.900000000)
|
||||
tdSql.checkData(0,4,3.000000000)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -361,7 +357,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,2.000000000)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -369,7 +365,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,2.000000000)
|
||||
|
||||
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) , round(abs(c1))-0.5 from ct4 where c1>log(c1,2) limit 1 ")
|
||||
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) , round(abs(c1))-0.5 from {dbname}.ct4 where c1>log(c1,2) limit 1 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,88888)
|
||||
|
@ -382,44 +378,42 @@ class TDTestCase:
|
|||
def round_Arithmetic(self):
|
||||
pass
|
||||
|
||||
def check_boundary_values(self):
|
||||
def check_boundary_values(self, dbname="bound_test"):
|
||||
|
||||
tdSql.execute("drop database if exists bound_test")
|
||||
tdSql.execute("create database if not exists bound_test")
|
||||
time.sleep(3)
|
||||
tdSql.execute("use bound_test")
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname}")
|
||||
tdSql.execute(
|
||||
"create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||
)
|
||||
tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )')
|
||||
tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )')
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
|
||||
tdSql.error(
|
||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select round(c1), round(c2) ,round(c3), round(c4), round(c5) ,round(c6) from sub1_bound")
|
||||
self.check_result_auto( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select round(c1), round(c2) ,round(c3), round(c3), round(c2) ,round(c1) from sub1_bound")
|
||||
self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from sub1_bound;" , "select round(c1) from sub1_bound" )
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select round(c1), round(c2) ,round(c3), round(c4), round(c5) ,round(c6) from {dbname}.sub1_bound")
|
||||
self.check_result_auto( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select round(c1), round(c2) ,round(c3), round(c3), round(c2) ,round(c1) from {dbname}.sub1_bound")
|
||||
self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.sub1_bound;" , f"select round(c1) from {dbname}.sub1_bound" )
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query("select round(c1+0.2) ,round(c2) , round(c3+0.3) , round(c4-0.3), round(c5/2), round(c6/2) from sub1_bound ")
|
||||
tdSql.query(f"select round(c1+0.2) ,round(c2) , round(c3+0.3) , round(c4-0.3), round(c5/2), round(c6/2) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0, 0, 2147483647.000000000)
|
||||
tdSql.checkData(0, 2, 32767.000000000)
|
||||
tdSql.checkData(0, 3, 127.000000000)
|
||||
|
@ -430,19 +424,18 @@ class TDTestCase:
|
|||
tdSql.checkData(4, 3, -123.000000000)
|
||||
tdSql.checkData(4, 4, -169499995645668991474575059260979281920.000000000)
|
||||
|
||||
self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from sub1_bound ")
|
||||
self.check_result_auto(f"select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from {dbname}.sub1_bound" ,f"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from {dbname}.sub1_bound ")
|
||||
|
||||
def support_super_table_test(self):
|
||||
tdSql.execute(" use db ")
|
||||
self.check_result_auto( " select c5 from stb1 order by ts " , "select round(c5) from stb1 order by ts" )
|
||||
self.check_result_auto( " select c5 from stb1 order by tbname " , "select round(c5) from stb1 order by tbname" )
|
||||
self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
def support_super_table_test(self, dbname="db"):
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 order by ts " , f"select round(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 order by tbname " , f"select round(c5) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select round(t1), round(c5) from stb1 order by ts" )
|
||||
self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select round(t1) ,round(c5) from stb1 order by tbname" )
|
||||
self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) ,round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) , round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select round(t1), round(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select round(t1) ,round(c5) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(t1) ,round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(t1) , round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -120,16 +120,16 @@ class TDTestCase:
|
|||
|
||||
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==========")
|
||||
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:
|
||||
self.__rtrim_check(tb)
|
||||
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==========")
|
||||
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 errsql in self.__rtrim_err_check(tb):
|
||||
|
@ -142,17 +142,15 @@ class TDTestCase:
|
|||
self.__test_error()
|
||||
|
||||
|
||||
def __create_tb(self):
|
||||
tdSql.prepare()
|
||||
|
||||
def __create_tb(self, dbname="db"):
|
||||
tdLog.printNoPrefix("==========step1:create table")
|
||||
create_stb_sql = f'''create table stb1(
|
||||
create_stb_sql = f'''create table {dbname}.stb1(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
) tags (t1 int)
|
||||
'''
|
||||
create_ntb_sql = f'''create table t1(
|
||||
create_ntb_sql = f'''create table {dbname}.t1(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
|
@ -162,29 +160,29 @@ class TDTestCase:
|
|||
tdSql.execute(create_ntb_sql)
|
||||
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||
|
||||
def __insert_data(self, rows):
|
||||
def __insert_data(self, rows, dbname="db"):
|
||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||
for i in range(rows):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f'''insert into ct1 values
|
||||
f'''insert into {dbname}.ct1 values
|
||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into ct4 values
|
||||
f'''insert into {dbname}.ct4 values
|
||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
@ -200,7 +198,7 @@ class TDTestCase:
|
|||
)
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into ct2 values
|
||||
f'''insert into {dbname}.ct2 values
|
||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
@ -216,13 +214,13 @@ class TDTestCase:
|
|||
)
|
||||
|
||||
for i in range(rows):
|
||||
insert_data = f'''insert into t1 values
|
||||
insert_data = f'''insert into {dbname}.t1 values
|
||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||
'''
|
||||
tdSql.execute(insert_data)
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
@ -251,8 +249,7 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("==========step3:all check")
|
||||
self.all_test()
|
||||
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.execute("flush database db")
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
||||
|
|
|
@ -11,21 +11,17 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pstats import Stats
|
||||
import sys
|
||||
import subprocess
|
||||
import random
|
||||
import math
|
||||
import numpy as np
|
||||
import inspect
|
||||
import re
|
||||
import taos
|
||||
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
DBNAME = "db"
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
|
@ -33,11 +29,11 @@ class TDTestCase:
|
|||
tdSql.init(conn.cursor())
|
||||
self.ts = 1537146000000
|
||||
|
||||
def sample_query_form(self, sel="select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr="t1", condition=""):
|
||||
def sample_query_form(self, sel=f"select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr="t1", condition=""):
|
||||
'''
|
||||
sample function:
|
||||
|
||||
:param sel: string, must be "select", required parameters;
|
||||
:param sel: string, must be f"select", required parameters;
|
||||
:param func: string, in this case must be "sample(", otherwise return other function, required parameters;
|
||||
:param col: string, column name, required parameters;
|
||||
:param m_comm: string, comma between col and k , required parameters;
|
||||
|
@ -47,12 +43,12 @@ class TDTestCase:
|
|||
:param fr: string, must be "from", required parameters;
|
||||
:param table_expr: string or expression, data source(eg,table/stable name, result set), required parameters;
|
||||
:param condition: expression;
|
||||
:return: sample query statement,default: select sample(c1, 1) from t1
|
||||
:return: sample query statement,default: select sample(c1, 1) from {dbname}.t1
|
||||
'''
|
||||
|
||||
return f"{sel} {func} {col} {m_comm} {k} {r_comm} {alias} {fr} {table_expr} {condition}"
|
||||
|
||||
def checksample(self,sel="select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr="t1", condition=""):
|
||||
def checksample(self,sel=f"select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr=f"{DBNAME}.t1", condition=""):
|
||||
# print(self.sample_query_form(sel=sel, func=func, col=col, m_comm=m_comm, k=k, r_comm=r_comm, alias=alias, fr=fr,
|
||||
# table_expr=table_expr, condition=condition))
|
||||
line = sys._getframe().f_back.f_lineno
|
||||
|
@ -65,7 +61,7 @@ class TDTestCase:
|
|||
))
|
||||
|
||||
|
||||
sql = "select * from t1"
|
||||
sql = f"select * from {table_expr}"
|
||||
collist = tdSql.getColNameList(sql)
|
||||
|
||||
if not isinstance(col, str):
|
||||
|
@ -125,7 +121,7 @@ class TDTestCase:
|
|||
# table_expr=table_expr, condition=condition
|
||||
# ))
|
||||
|
||||
if any( [func != "sample(" , r_comm != ")" , fr != "from", sel != "select"]):
|
||||
if any( [func != "sample(" , r_comm != ")" , fr != "from", sel != f"select"]):
|
||||
print(f"case in {line}: ", end='')
|
||||
return tdSql.error(self.sample_query_form(
|
||||
sel=sel, func=func, col=col, m_comm=m_comm, k=k, r_comm=r_comm, alias=alias, fr=fr,
|
||||
|
@ -286,14 +282,14 @@ class TDTestCase:
|
|||
return
|
||||
|
||||
else:
|
||||
if "where" in condition:
|
||||
condition = re.sub('where', f"where {col} is not null and ", condition)
|
||||
else:
|
||||
condition = f"where {col} is not null" + condition
|
||||
print(f"select ts, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}")
|
||||
tdSql.query(f"select ts, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}")
|
||||
# if "where" in condition:
|
||||
# condition = re.sub('where', f"where {col} is not null and ", condition)
|
||||
# else:
|
||||
# condition = f"where {col} is not null" + condition
|
||||
# print(f"select ts, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}")
|
||||
# tdSql.query(f"select _c0, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}")
|
||||
# offset_val = condition.split("offset")[1].split(" ")[1] if "offset" in condition else 0
|
||||
pre_sample = tdSql.queryResult
|
||||
# pre_sample = tdSql.queryResult
|
||||
# pre_len = tdSql.queryRows
|
||||
# for i in range(sample_len):
|
||||
# if sample_result[pre_row:pre_row + step][i] not in pre_sample:
|
||||
|
@ -301,7 +297,7 @@ class TDTestCase:
|
|||
# else:
|
||||
# tdLog.info(f"case in {line} is success: sample data is in {group_name}")
|
||||
|
||||
pass
|
||||
pass
|
||||
|
||||
def sample_current_query(self) :
|
||||
|
||||
|
@ -322,24 +318,24 @@ class TDTestCase:
|
|||
self.checksample(**case6)
|
||||
|
||||
# # case7~8: nested query
|
||||
# case7 = {"table_expr": "(select c1 from stb1)"}
|
||||
# self.checksample(**case7)
|
||||
# case8 = {"table_expr": "(select sample(c1, 1) c1 from stb1 group by tbname)"}
|
||||
# self.checksample(**case8)
|
||||
case7 = {"table_expr": f"(select c1 from {DBNAME}.stb1)"}
|
||||
self.checksample(**case7)
|
||||
case8 = {"table_expr": f"(select sample(c1, 1) c1 from {DBNAME}.stb1 group by tbname)"}
|
||||
self.checksample(**case8)
|
||||
|
||||
# case9~10: mix with tbname/ts/tag/col
|
||||
# case9 = {"alias": ", tbname"}
|
||||
# self.checksample(**case9)
|
||||
# case10 = {"alias": ", _c0"}
|
||||
# self.checksample(**case10)
|
||||
# case11 = {"alias": ", st1"}
|
||||
case9 = {"alias": ", tbname"}
|
||||
self.checksample(**case9)
|
||||
case10 = {"alias": ", _c0"}
|
||||
self.checksample(**case10)
|
||||
case11 = {"alias": ", st1"}
|
||||
# self.checksample(**case11)
|
||||
tdSql.query("select sample( c1 , 1 ) , st1 from t1")
|
||||
tdSql.query(f"select sample( c1 , 1 ) , st1 from {DBNAME}.t1")
|
||||
|
||||
# case12 = {"alias": ", c1"}
|
||||
case12 = {"alias": ", c1"}
|
||||
# self.checksample(**case12)
|
||||
|
||||
tdSql.query("select sample( c1 , 1 ) , c1 from t1")
|
||||
tdSql.query(f"select sample( c1 , 1 ) , c1 from {DBNAME}.t1")
|
||||
|
||||
# case13~15: with single condition
|
||||
case13 = {"condition": "where c1 <= 10"}
|
||||
|
@ -353,32 +349,31 @@ class TDTestCase:
|
|||
case16 = {"condition": "where c6=1 or c6 =0"}
|
||||
self.checksample(**case16)
|
||||
|
||||
# # case17: only support normal table join
|
||||
# case17 = {
|
||||
# "col": "t1.c1",
|
||||
# "table_expr": "t1, t2",
|
||||
# "condition": "where t1.ts=t2.ts"
|
||||
# }
|
||||
# self.checksample(**case17)
|
||||
# # case18~19: with group by
|
||||
# case19 = {
|
||||
# "table_expr": "stb1",
|
||||
# "condition": "partition by tbname"
|
||||
# }
|
||||
# case17: only support normal table join
|
||||
case17 = {
|
||||
"col": "t1.c1",
|
||||
"table_expr": f"{DBNAME}.t1 t1 join {DBNAME}.t2 t2 on t1.ts = t2.ts",
|
||||
}
|
||||
self.checksample(**case17)
|
||||
# case18~19: with group by
|
||||
case19 = {
|
||||
"table_expr": f"{DBNAME}.stb1",
|
||||
"condition": "partition by tbname"
|
||||
}
|
||||
# self.checksample(**case19)
|
||||
|
||||
# # case20~21: with order by
|
||||
# case20 = {"condition": "order by ts"}
|
||||
# case20~21: with order by
|
||||
case20 = {"condition": "order by ts"}
|
||||
# self.checksample(**case20)
|
||||
# case21 = {
|
||||
# "table_expr": "stb1",
|
||||
# "condition": "partition by tbname order by tbname"
|
||||
# }
|
||||
case21 = {
|
||||
"table_expr": f"{DBNAME}.stb1",
|
||||
"condition": "partition by tbname order by tbname"
|
||||
}
|
||||
# self.checksample(**case21)
|
||||
|
||||
# case22: with union
|
||||
case22 = {
|
||||
"condition": "union all select sample( c1 , 1 ) from t2"
|
||||
"condition": f"union all select sample( c1 , 1 ) from {DBNAME}.t2"
|
||||
}
|
||||
self.checksample(**case22)
|
||||
|
||||
|
@ -396,12 +391,12 @@ class TDTestCase:
|
|||
case26 = {"k": 1000}
|
||||
self.checksample(**case26)
|
||||
case27 = {
|
||||
"table_expr": "stb1",
|
||||
"table_expr": f"{DBNAME}.stb1",
|
||||
"condition": "group by tbname slimit 1 "
|
||||
}
|
||||
self.checksample(**case27) # with slimit
|
||||
case28 = {
|
||||
"table_expr": "stb1",
|
||||
"table_expr": f"{DBNAME}.stb1",
|
||||
"condition": "group by tbname slimit 1 soffset 1"
|
||||
}
|
||||
self.checksample(**case28) # with soffset
|
||||
|
@ -431,7 +426,7 @@ class TDTestCase:
|
|||
|
||||
# err9 = {"col": "st1"}
|
||||
# self.checksample(**err9) # col: tag
|
||||
tdSql.query(" select sample(st1 ,1) from t1 ")
|
||||
tdSql.query(f"select sample(st1 ,1) from {DBNAME}.t1 ")
|
||||
# err10 = {"col": 1}
|
||||
# self.checksample(**err10) # col: value
|
||||
# err11 = {"col": "NULL"}
|
||||
|
@ -494,13 +489,13 @@ class TDTestCase:
|
|||
self.checksample(**err39) # mix with calculation function 2
|
||||
# err40 = {"alias": "+ 2"}
|
||||
# self.checksample(**err40) # mix with arithmetic 1
|
||||
# tdSql.query(" select sample(c1 , 1) + 2 from t1 ")
|
||||
# tdSql.query(f"select sample(c1 , 1) + 2 from {dbname}.t1 ")
|
||||
err41 = {"alias": "+ avg(c1)"}
|
||||
# self.checksample(**err41) # mix with arithmetic 2
|
||||
|
||||
# err42 = {"alias": ", c1"}
|
||||
# self.checksample(**err42)
|
||||
tdSql.query("select sample( c1 , 1 ) , c1 from t1")
|
||||
tdSql.query(f"select sample( c1 , 1 ) , c1 from {DBNAME}.t1")
|
||||
# mix with other col
|
||||
# err43 = {"table_expr": "stb1"}
|
||||
# self.checksample(**err43) # select stb directly
|
||||
|
@ -510,14 +505,14 @@ class TDTestCase:
|
|||
# "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts"
|
||||
# }
|
||||
# self.checksample(**err44) # stb join
|
||||
tdSql.query("select sample( stb1.c1 , 1 ) from stb1, stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts")
|
||||
tdSql.query(f"select sample( 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 = {
|
||||
# "condition": "where ts>0 and ts < now interval(1h) fill(next)"
|
||||
# }
|
||||
# self.checksample(**err45) # interval
|
||||
tdSql.error("select sample( c1 , 1 ) from t1 where ts>0 and ts < now interval(1h) fill(next)")
|
||||
tdSql.error(f"select sample( c1 , 1 ) from {DBNAME}.t1 where ts>0 and ts < now interval(1h) fill(next)")
|
||||
err46 = {
|
||||
"table_expr": "t1",
|
||||
"table_expr": f"{DBNAME}.t1",
|
||||
"condition": "group by c6"
|
||||
}
|
||||
# self.checksample(**err46) # group by normal col
|
||||
|
@ -563,49 +558,45 @@ class TDTestCase:
|
|||
|
||||
pass
|
||||
|
||||
def sample_test_data(self, tbnum:int, data_row:int, basetime:int) -> None :
|
||||
def sample_test_data(self, tbnum:int, data_row:int, basetime:int, dbname="db") -> None :
|
||||
for i in range(tbnum):
|
||||
for j in range(data_row):
|
||||
tdSql.execute(
|
||||
f"insert into t{i} values ("
|
||||
f"insert into {dbname}.t{i} values ("
|
||||
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"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )"
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f"insert into t{i} values ("
|
||||
f"insert into {dbname}.t{i} values ("
|
||||
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"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )"
|
||||
f"insert into {dbname}.tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )"
|
||||
)
|
||||
|
||||
pass
|
||||
|
||||
def sample_test_table(self,tbnum: int) -> None :
|
||||
tdSql.execute("drop database if exists db")
|
||||
tdSql.execute("create database if not exists db keep 3650")
|
||||
tdSql.execute("use db")
|
||||
def sample_test_table(self,tbnum: int, dbname="db") -> None :
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname} keep 3650")
|
||||
|
||||
tdSql.execute(
|
||||
"create stable db.stb1 (\
|
||||
f"create stable {dbname}.stb1 (\
|
||||
ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool, \
|
||||
c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16)\
|
||||
) \
|
||||
tags(st1 int)"
|
||||
)
|
||||
tdSql.execute(
|
||||
"create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)"
|
||||
f"create stable {dbname}.stb2 (ts timestamp, c1 int) tags(st2 int)"
|
||||
)
|
||||
for i in range(tbnum):
|
||||
tdSql.execute(f"create table t{i} using stb1 tags({i})")
|
||||
tdSql.execute(f"create table tt{i} using stb2 tags({i})")
|
||||
|
||||
pass
|
||||
|
||||
tdSql.execute(f"create table {dbname}.t{i} using {dbname}.stb1 tags({i})")
|
||||
tdSql.execute(f"create table {dbname}.tt{i} using {dbname}.stb2 tags({i})")
|
||||
|
||||
def check_sample(self , sample_query , origin_query ):
|
||||
|
||||
|
@ -626,45 +617,43 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.exit(" sample data is not in datas groups ,failed sql is : %s" % sample_query )
|
||||
|
||||
|
||||
def basic_sample_query(self):
|
||||
tdSql.execute(" drop database if exists db ")
|
||||
tdSql.execute(" create database if not exists db duration 300d ")
|
||||
tdSql.execute(" use db ")
|
||||
def basic_sample_query(self, dbname="db"):
|
||||
tdSql.execute(f" drop database if exists {dbname} ")
|
||||
tdSql.execute(f" create database if not exists {dbname} duration 300d ")
|
||||
tdSql.execute(
|
||||
'''create table stb1
|
||||
f'''create table {dbname}.stb1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
create table {dbname}.t1
|
||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||
'''
|
||||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||
|
||||
for i in range(9):
|
||||
tdSql.execute(
|
||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||
)
|
||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||
|
||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||
|
||||
tdSql.execute(
|
||||
f'''insert into t1 values
|
||||
f'''insert into {dbname}.t1 values
|
||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||
|
@ -683,116 +672,116 @@ class TDTestCase:
|
|||
# basic query for sample
|
||||
|
||||
# params test for all
|
||||
tdSql.error(" select sample(c1,c1) from t1 ")
|
||||
tdSql.error(" select sample(c1,now) from t1 ")
|
||||
tdSql.error(" select sample(c1,tbname) from t1 ")
|
||||
tdSql.error(" select sample(c1,ts) from t1 ")
|
||||
tdSql.error(" select sample(c1,false) from t1 ")
|
||||
tdSql.query(" select sample(123,1) from t1 ")
|
||||
tdSql.error(f"select sample(c1,c1) from {dbname}.t1 ")
|
||||
tdSql.error(f"select sample(c1,now) from {dbname}.t1 ")
|
||||
tdSql.error(f"select sample(c1,tbname) from {dbname}.t1 ")
|
||||
tdSql.error(f"select sample(c1,ts) from {dbname}.t1 ")
|
||||
tdSql.error(f"select sample(c1,false) from {dbname}.t1 ")
|
||||
tdSql.query(f"select sample(123,1) from {dbname}.t1 ")
|
||||
|
||||
tdSql.query(" select sample(c1,2) from t1 ")
|
||||
tdSql.query(f"select sample(c1,2) from {dbname}.t1 ")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.query(" select sample(c1,10) from t1 ")
|
||||
tdSql.query(f"select sample(c1,10) from {dbname}.t1 ")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query(" select sample(c8,10) from t1 ")
|
||||
tdSql.query(f"select sample(c8,10) from {dbname}.t1 ")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query(" select sample(c1,999) from t1 ")
|
||||
tdSql.query(f"select sample(c1,999) from {dbname}.t1 ")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query(" select sample(c1,1000) from t1 ")
|
||||
tdSql.query(f"select sample(c1,1000) from {dbname}.t1 ")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query(" select sample(c8,1000) from t1 ")
|
||||
tdSql.query(f"select sample(c8,1000) from {dbname}.t1 ")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.error(" select sample(c1,-1) from t1 ")
|
||||
tdSql.error(f"select sample(c1,-1) from {dbname}.t1 ")
|
||||
|
||||
# bug need fix
|
||||
# tdSql.query("select sample(c1 ,2) , 123 from stb1;")
|
||||
# tdSql.query(f"select sample(c1 ,2) , 123 from {dbname}.stb1;")
|
||||
|
||||
# all type support
|
||||
tdSql.query(" select sample(c1 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c1 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c2 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c2 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c3 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c3 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c4 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c4 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c5 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c5 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c6 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c6 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c7 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c7 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c8 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c8 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c9 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c9 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query(" select sample(c10 , 20 ) from ct4 ")
|
||||
tdSql.query(f"select sample(c10 , 20 ) from {dbname}.ct4 ")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
# tdSql.query(" select sample(t1 , 20 ) from ct1 ")
|
||||
# tdSql.query(f"select sample(t1 , 20 ) from {dbname}.ct1 ")
|
||||
# tdSql.checkRows(13)
|
||||
# filter data
|
||||
|
||||
tdSql.query(" select sample(c1, 20 ) from t1 where c1 is null ")
|
||||
tdSql.query(f"select sample(c1, 20 ) from {dbname}.t1 where c1 is null ")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query(" select sample(c1, 20 ) from t1 where c1 =6 ")
|
||||
tdSql.query(f"select sample(c1, 20 ) from {dbname}.t1 where c1 =6 ")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query(" select sample(c1, 20 ) from t1 where c1 > 6 ")
|
||||
tdSql.query(f"select sample(c1, 20 ) from {dbname}.t1 where c1 > 6 ")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
self.check_sample("select sample(c1, 20 ) from t1 where c1 > 6" , "select c1 from t1 where c1 > 6")
|
||||
self.check_sample(f"select sample(c1, 20 ) from {dbname}.t1 where c1 > 6" , f"select c1 from {dbname}.t1 where c1 > 6")
|
||||
|
||||
tdSql.query(" select sample( c1 , 1 ) from t1 where c1 in (0, 1,2) ")
|
||||
tdSql.query(f"select sample( c1 , 1 ) from {dbname}.t1 where c1 in (0, 1,2) ")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query("select sample( c1 ,3 ) from t1 where c1 between 1 and 10 ")
|
||||
tdSql.query(f"select sample( c1 ,3 ) from {dbname}.t1 where c1 between 1 and 10 ")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
self.check_sample("select sample( c1 ,3 ) from t1 where c1 between 1 and 10" ,"select c1 from t1 where c1 between 1 and 10")
|
||||
self.check_sample(f"select sample( c1 ,3 ) from {dbname}.t1 where c1 between 1 and 10" ,f"select c1 from {dbname}.t1 where c1 between 1 and 10")
|
||||
|
||||
# join
|
||||
|
||||
tdSql.query("select sample( ct4.c1 , 1 ) from ct1, ct4 where ct4.ts=ct1.ts")
|
||||
tdSql.query(f"select sample( ct4.c1 , 1 ) from {dbname}.ct1 ct1, {dbname}.ct4 ct4 where ct4.ts=ct1.ts")
|
||||
|
||||
# partition by tbname
|
||||
|
||||
tdSql.query("select sample(c1,2) from stb1 partition by tbname")
|
||||
tdSql.query(f"select sample(c1,2) from {dbname}.stb1 partition by tbname")
|
||||
tdSql.checkRows(4)
|
||||
|
||||
self.check_sample("select sample(c1,2) from stb1 partition by tbname" , "select c1 from stb1 partition by tbname")
|
||||
self.check_sample(f"select sample(c1,2) from {dbname}.stb1 partition by tbname" , f"select c1 from {dbname}.stb1 partition by tbname")
|
||||
|
||||
# nest query
|
||||
# tdSql.query("select sample(c1,2) from (select c1 from t1); ")
|
||||
# tdSql.query(f"select sample(c1,2) from (select c1 from {dbname}.t1); ")
|
||||
# tdSql.checkRows(2)
|
||||
|
||||
# union all
|
||||
tdSql.query("select sample(c1,2) from t1 union all select sample(c1,3) from t1")
|
||||
tdSql.query(f"select sample(c1,2) from {dbname}.t1 union all select sample(c1,3) from {dbname}.t1")
|
||||
tdSql.checkRows(5)
|
||||
|
||||
# fill interval
|
||||
|
||||
# not support mix with other function
|
||||
tdSql.error("select top(c1,2) , sample(c1,2) from ct1")
|
||||
tdSql.error("select max(c1) , sample(c1,2) from ct1")
|
||||
tdSql.query("select c1 , sample(c1,2) from ct1")
|
||||
tdSql.error(f"select top(c1,2) , sample(c1,2) from {dbname}.ct1")
|
||||
tdSql.error(f"select max(c1) , sample(c1,2) from {dbname}.ct1")
|
||||
tdSql.query(f"select c1 , sample(c1,2) from {dbname}.ct1")
|
||||
|
||||
# bug for mix with scalar
|
||||
tdSql.query("select 123 , sample(c1,100) from ct1")
|
||||
tdSql.query("select sample(c1,100)+2 from ct1")
|
||||
tdSql.query("select abs(sample(c1,100)) from ct1")
|
||||
tdSql.query(f"select 123 , sample(c1,100) from {dbname}.ct1")
|
||||
tdSql.query(f"select sample(c1,100)+2 from {dbname}.ct1")
|
||||
tdSql.query(f"select abs(sample(c1,100)) from {dbname}.ct1")
|
||||
|
||||
def sample_test_run(self) :
|
||||
def sample_test_run(self, dbname="db") :
|
||||
tdLog.printNoPrefix("==========support sample function==========")
|
||||
tbnum = 10
|
||||
nowtime = int(round(time.time() * 1000))
|
||||
|
@ -805,28 +794,28 @@ class TDTestCase:
|
|||
|
||||
tdLog.printNoPrefix("######## insert only NULL test:")
|
||||
for i in range(tbnum):
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime - 5})")
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime + 5})")
|
||||
tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime - 5})")
|
||||
tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime + 5})")
|
||||
self.sample_current_query()
|
||||
self.sample_error_query()
|
||||
|
||||
tdLog.printNoPrefix("######## insert data in the range near the max(bigint/double):")
|
||||
# self.sample_test_table(tbnum)
|
||||
# tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values "
|
||||
# f"({nowtime - (per_table_rows + 1) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})")
|
||||
# tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values "
|
||||
# f"({nowtime - (per_table_rows + 2) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})")
|
||||
# self.sample_current_query()
|
||||
# self.sample_error_query()
|
||||
self.sample_test_table(tbnum)
|
||||
tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values "
|
||||
f"({nowtime - (per_table_rows + 1) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})")
|
||||
tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values "
|
||||
f"({nowtime - (per_table_rows + 2) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})")
|
||||
self.sample_current_query()
|
||||
self.sample_error_query()
|
||||
|
||||
tdLog.printNoPrefix("######## insert data in the range near the min(bigint/double):")
|
||||
# self.sample_test_table(tbnum)
|
||||
# tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values "
|
||||
# f"({nowtime - (per_table_rows + 1) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {1-2**63})")
|
||||
# tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values "
|
||||
# f"({nowtime - (per_table_rows + 2) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {512-2**63})")
|
||||
# self.sample_current_query()
|
||||
# self.sample_error_query()
|
||||
self.sample_test_table(tbnum)
|
||||
tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values "
|
||||
f"({nowtime - (per_table_rows + 1) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {1-2**63})")
|
||||
tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values "
|
||||
f"({nowtime - (per_table_rows + 2) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {512-2**63})")
|
||||
self.sample_current_query()
|
||||
self.sample_error_query()
|
||||
|
||||
tdLog.printNoPrefix("######## insert data without NULL data test:")
|
||||
self.sample_test_table(tbnum)
|
||||
|
@ -837,16 +826,16 @@ class TDTestCase:
|
|||
|
||||
tdLog.printNoPrefix("######## insert data mix with NULL test:")
|
||||
for i in range(tbnum):
|
||||
tdSql.execute(f"insert into 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 t{i}(ts) values ({nowtime+(per_table_rows+3)*10})")
|
||||
tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime})")
|
||||
tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime-(per_table_rows+3)*10})")
|
||||
tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime+(per_table_rows+3)*10})")
|
||||
self.sample_current_query()
|
||||
self.sample_error_query()
|
||||
|
||||
|
||||
|
||||
tdLog.printNoPrefix("######## check after WAL test:")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
tdSql.query(f"select * from information_schema.ins_dnodes")
|
||||
index = tdSql.getData(0, 0)
|
||||
tdDnodes.stop(index)
|
||||
tdDnodes.start(index)
|
||||
|
@ -855,25 +844,25 @@ class TDTestCase:
|
|||
|
||||
self.basic_sample_query()
|
||||
|
||||
def sample_big_data(self):
|
||||
tdSql.execute("create database sample_db")
|
||||
def sample_big_data(self, dbname="sample_db"):
|
||||
tdSql.execute(f"create database {dbname}")
|
||||
tdSql.execute("use sample_db")
|
||||
tdSql.execute("create stable st (ts timestamp ,c1 int ) tags(ind int)" )
|
||||
tdSql.execute("create table sub_tb using st tags(1)")
|
||||
tdSql.execute(f"create stable {dbname}.st (ts timestamp ,c1 int ) tags(ind int)" )
|
||||
tdSql.execute(f"create table {dbname}.sub_tb using {dbname}.st tags(1)")
|
||||
|
||||
for i in range(2000):
|
||||
ts = self.ts+i*10
|
||||
tdSql.execute(f"insert into sub_tb values({ts} ,{i})")
|
||||
tdSql.execute(f"insert into {dbname}.sub_tb values({ts} ,{i})")
|
||||
|
||||
tdSql.query("select count(*) from st")
|
||||
tdSql.query(f"select count(*) from {dbname}.st")
|
||||
tdSql.checkData(0,0,2000)
|
||||
tdSql.query("select sample(c1 ,1000) from st")
|
||||
tdSql.query(f"select sample(c1 ,1000) from {dbname}.st")
|
||||
tdSql.checkRows(1000)
|
||||
|
||||
# bug need fix
|
||||
tdSql.query("select c1 ,t1, sample(c1,2) from db.stb1 partition by c1 ")
|
||||
tdSql.query("select sample(c1,2) from db.stb1 partition by c1 ")
|
||||
# tdSql.query("select c1 ,ind, sample(c1,2) from sample_db.st partition by c1 ")
|
||||
tdSql.query(f"select c1 ,t1, sample(c1,2) from db.stb1 partition by c1 ")
|
||||
tdSql.query(f"select sample(c1,2) from db.stb1 partition by c1 ")
|
||||
# tdSql.query(f"select c1 ,ind, sample(c1,2) from {dbname}.sample_db.st partition by c1 ")
|
||||
|
||||
def run(self):
|
||||
import traceback
|
||||
|
|
|
@ -138,6 +138,14 @@ python3 ./test.py -f 2-query/percentile.py
|
|||
python3 ./test.py -f 2-query/percentile.py -R
|
||||
python3 ./test.py -f 2-query/pow.py
|
||||
python3 ./test.py -f 2-query/pow.py -R
|
||||
python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
||||
python3 ./test.py -f 2-query/query_cols_tags_and_or.py -R
|
||||
python3 ./test.py -f 2-query/round.py
|
||||
python3 ./test.py -f 2-query/round.py -R
|
||||
python3 ./test.py -f 2-query/rtrim.py
|
||||
# python3 ./test.py -f 2-query/rtrim.py -R
|
||||
python3 ./test.py -f 2-query/sample.py
|
||||
python3 ./test.py -f 2-query/sample.py -R
|
||||
|
||||
|
||||
python3 ./test.py -f 1-insert/update_data.py
|
||||
|
@ -145,7 +153,6 @@ python3 ./test.py -f 1-insert/update_data.py
|
|||
python3 ./test.py -f 1-insert/delete_data.py
|
||||
|
||||
python3 ./test.py -f 2-query/varchar.py
|
||||
python3 ./test.py -f 2-query/rtrim.py
|
||||
python3 ./test.py -f 2-query/upper.py
|
||||
python3 ./test.py -f 2-query/lower.py
|
||||
python3 ./test.py -f 2-query/join2.py
|
||||
|
@ -165,12 +172,10 @@ python3 ./test.py -f 2-query/Timediff.py
|
|||
python3 ./test.py -f 2-query/json_tag.py
|
||||
|
||||
python3 ./test.py -f 2-query/top.py
|
||||
python3 ./test.py -f 2-query/round.py
|
||||
python3 ./test.py -f 2-query/log.py
|
||||
python3 ./test.py -f 2-query/sqrt.py
|
||||
python3 ./test.py -f 2-query/sin.py
|
||||
python3 ./test.py -f 2-query/tan.py
|
||||
python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
||||
# python3 ./test.py -f 2-query/nestedQuery.py
|
||||
# TD-15983 subquery output duplicate name column.
|
||||
# Please Xiangyang Guo modify the following script
|
||||
|
@ -179,7 +184,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
|||
python3 ./test.py -f 2-query/elapsed.py
|
||||
python3 ./test.py -f 2-query/csum.py
|
||||
#python3 ./test.py -f 2-query/mavg.py
|
||||
python3 ./test.py -f 2-query/sample.py
|
||||
python3 ./test.py -f 2-query/function_diff.py
|
||||
python3 ./test.py -f 2-query/unique.py
|
||||
python3 ./test.py -f 2-query/stateduration.py
|
||||
|
|
Loading…
Reference in New Issue