[TS-4893]<test>: add CI test cases test_function
This commit is contained in:
parent
63e6a2d433
commit
b836235b67
|
@ -0,0 +1,21 @@
|
||||||
|
0.663936012733698
|
||||||
|
0.840187717154710
|
||||||
|
0.840187717154710
|
||||||
|
0.700976369297587
|
||||||
|
0.561380175203728
|
||||||
|
0.916457875592847
|
||||||
|
0.274745596235034
|
||||||
|
0.135438768721856
|
||||||
|
0.486904139391568
|
||||||
|
0.352760728612896
|
||||||
|
0.206965447965528
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
||||||
|
0.419929514834624
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
select RAND(1245);
|
||||||
|
select RAND(id) from ts_4893.d0 limit 10;
|
||||||
|
select RAND(id) from ts_4893.d0 order by id desc limit 10;
|
|
@ -509,31 +509,98 @@ class TDTestCase(TBase):
|
||||||
tdSql.error(
|
tdSql.error(
|
||||||
"select * from (select to_iso8601(ts, timezone()), timezone() from meters order by ts desc) limit 1000;",
|
"select * from (select to_iso8601(ts, timezone()), timezone() from meters order by ts desc) limit 1000;",
|
||||||
expectErrInfo="Not supported timzone format") # TS-5340
|
expectErrInfo="Not supported timzone format") # TS-5340
|
||||||
|
|
||||||
|
def test_rand(self):
|
||||||
|
self.test_normal_query("rand")
|
||||||
|
|
||||||
|
tdSql.query("select rand();")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkCols(1)
|
||||||
|
self.check_result_in_range(0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select rand(null);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkCols(1)
|
||||||
|
self.check_result_in_range(0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select rand() from (select 1) t limit 1;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkCols(1)
|
||||||
|
self.check_result_in_range(0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select rand(id) from ts_4893.d0 limit 100;")
|
||||||
|
tdSql.checkRows(100)
|
||||||
|
tdSql.checkCols(1)
|
||||||
|
for i in range(len(tdSql.res)):
|
||||||
|
self.check_result_in_range(i, 0)
|
||||||
|
|
||||||
|
tdSql.query("select rand(id) from ts_4893.meters limit 100;")
|
||||||
|
tdSql.checkRows(100)
|
||||||
|
tdSql.checkCols(1)
|
||||||
|
for i in range(len(tdSql.res)):
|
||||||
|
self.check_result_in_range(i, 0)
|
||||||
|
|
||||||
|
tdSql.query("select rand(123), rand(123);")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkCols(2)
|
||||||
|
if tdSql.res[0][0] != tdSql.res[0][1]:
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, tdSql.sql, tdSql.res[0][0], tdSql.res[0][1])
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s data1:%s ne data2:%s" % args)
|
||||||
|
|
||||||
|
def check_result_in_range(self, row, col):
|
||||||
|
res = tdSql.res[row][col]
|
||||||
|
if res < 0 or res >= 1:
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, tdSql.sql, row, col, res)
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s row:%s col:%s data:%s lt 0 or ge 1" % args)
|
||||||
|
|
||||||
|
def test_max(self):
|
||||||
|
self.test_normal_query("max")
|
||||||
|
|
||||||
|
tdSql.query("select max(null) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkCols(1)
|
||||||
|
tdSql.checkData(0, 0, 'None')
|
||||||
|
|
||||||
|
tdSql.query("select max(id) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query("select max(name) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query("select max(current) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query("select max(nch1) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query("select max(var1) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
def test_min(self):
|
def test_min(self):
|
||||||
self.test_normal_query("min")
|
self.test_normal_query("min")
|
||||||
|
|
||||||
tdSql.query("select min(var1), min(id) from ts_4893.d0;")
|
tdSql.query("select min(null) from ts_4893.meters;")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0, 0, 'abc一二三abc一二三abc')
|
tdSql.checkCols(1)
|
||||||
tdSql.checkData(0, 1, 0)
|
tdSql.checkData(0, 0, 'None')
|
||||||
def test_max(self):
|
|
||||||
self.test_normal_query("max")
|
tdSql.query("select min(id) from ts_4893.meters;")
|
||||||
tdSql.query("select max(var1), max(id) from ts_4893.d0;")
|
|
||||||
tdSql.checkRows(1)
|
|
||||||
tdSql.checkData(0, 0, '一二三四五六七八九十')
|
|
||||||
tdSql.checkData(0, 1, 9999)
|
|
||||||
def test_rand(self):
|
|
||||||
tdSql.query("select rand();")
|
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
tdSql.query("select rand(1);")
|
tdSql.query("select min(name) from ts_4893.meters;")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
tdSql.query("select rand(1) from ts_4893.meters limit 10;")
|
tdSql.query("select min(current) from ts_4893.meters;")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query("select min(nch1) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query("select min(var1) from ts_4893.meters;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
tdSql.query("select rand(id) from ts_4893.d0 limit 10;")
|
|
||||||
tdSql.checkRows(10)
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
@ -576,8 +643,8 @@ class TDTestCase(TBase):
|
||||||
self.test_varpop()
|
self.test_varpop()
|
||||||
|
|
||||||
# select function
|
# select function
|
||||||
self.test_min()
|
|
||||||
self.test_max()
|
self.test_max()
|
||||||
|
self.test_min()
|
||||||
|
|
||||||
# error function
|
# error function
|
||||||
self.test_error()
|
self.test_error()
|
||||||
|
|
Loading…
Reference in New Issue