update sample function for new feature

This commit is contained in:
wenzhouwww@live.cn 2022-06-13 11:18:06 +08:00
parent 13907386fb
commit dd22c92956
1 changed files with 33 additions and 24 deletions

View File

@ -331,10 +331,14 @@ class TDTestCase:
# self.checksample(**case9) # self.checksample(**case9)
# case10 = {"alias": ", _c0"} # case10 = {"alias": ", _c0"}
# self.checksample(**case10) # self.checksample(**case10)
case11 = {"alias": ", st1"} # case11 = {"alias": ", st1"}
self.checksample(**case11) # self.checksample(**case11)
case12 = {"alias": ", c1"} tdSql.query("select sample( c1 , 1 ) , st1 from t1")
self.checksample(**case12)
# case12 = {"alias": ", c1"}
# self.checksample(**case12)
tdSql.query("select sample( c1 , 1 ) , c1 from t1")
# case13~15: with single condition # case13~15: with single condition
case13 = {"condition": "where c1 <= 10"} case13 = {"condition": "where c1 <= 10"}
@ -491,21 +495,26 @@ class TDTestCase:
# self.checksample(**err40) # mix with arithmetic 1 # self.checksample(**err40) # mix with arithmetic 1
# tdSql.query(" select sample(c1 , 1) + 2 from t1 ") # tdSql.query(" select sample(c1 , 1) + 2 from t1 ")
err41 = {"alias": "+ avg(c1)"} err41 = {"alias": "+ avg(c1)"}
self.checksample(**err41) # mix with arithmetic 2 # self.checksample(**err41) # mix with arithmetic 2
err42 = {"alias": ", c1"}
self.checksample(**err42) # mix with other col # err42 = {"alias": ", c1"}
# self.checksample(**err42)
tdSql.query("select sample( c1 , 1 ) , c1 from t1")
# mix with other col
# err43 = {"table_expr": "stb1"} # err43 = {"table_expr": "stb1"}
# self.checksample(**err43) # select stb directly # self.checksample(**err43) # select stb directly
err44 = { # err44 = {
"col": "stb1.c1", # "col": "stb1.c1",
"table_expr": "stb1, stb2", # "table_expr": "stb1, stb2",
"condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" # "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts"
} # }
self.checksample(**err44) # stb join # self.checksample(**err44) # stb join
err45 = { tdSql.query("select sample( stb1.c1 , 1 ) from stb1, stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts")
"condition": "where ts>0 and ts < now interval(1h) fill(next)" # err45 = {
} # "condition": "where ts>0 and ts < now interval(1h) fill(next)"
self.checksample(**err45) # interval # }
# self.checksample(**err45) # interval
tdSql.query("select sample( c1 , 1 ) from t1 where ts>0 and ts < now interval(1h) fill(next)")
err46 = { err46 = {
"table_expr": "t1", "table_expr": "t1",
"condition": "group by c6" "condition": "group by c6"
@ -728,8 +737,8 @@ class TDTestCase:
tdSql.query(" select sample(c10 , 20 ) from ct4 ") tdSql.query(" select sample(c10 , 20 ) from ct4 ")
tdSql.checkRows(9) tdSql.checkRows(9)
tdSql.query(" select sample(t1 , 20 ) from ct1 ") # tdSql.query(" select sample(t1 , 20 ) from ct1 ")
tdSql.checkRows(13) # tdSql.checkRows(13)
# filter data # filter data
tdSql.query(" select sample(c1, 20 ) from t1 where c1 is null ") tdSql.query(" select sample(c1, 20 ) from t1 where c1 is null ")
@ -775,15 +784,15 @@ class TDTestCase:
# not support mix with other function # not support mix with other function
tdSql.error("select top(c1,2) , sample(c1,2) from ct1") tdSql.error("select top(c1,2) , sample(c1,2) from ct1")
tdSql.error("select max(c1) , sample(c1,2) from ct1") tdSql.error("select max(c1) , sample(c1,2) from ct1")
tdSql.error("select c1 , sample(c1,2) from ct1") tdSql.query("select c1 , sample(c1,2) from ct1")
# bug for mix with scalar # bug for mix with scalar
# tdSql.error("select 123 , sample(c1,100) from ct1") tdSql.query("select 123 , sample(c1,100) from ct1")
# tdSql.error("select sample(c1,100)+2 from ct1") tdSql.query("select sample(c1,100)+2 from ct1")
# tdSql.error("select abs(sample(c1,100)) from ct1") tdSql.query("select abs(sample(c1,100)) from ct1")
def sample_test_run(self) : def sample_test_run(self) :
tdLog.printNoPrefix("==========TD-10594==========") tdLog.printNoPrefix("==========support sample function==========")
tbnum = 10 tbnum = 10
nowtime = int(round(time.time() * 1000)) nowtime = int(round(time.time() * 1000))
per_table_rows = 10 per_table_rows = 10