未验证 提交 8bd24a57 编写于 作者: W wenzhouwww 提交者: GitHub

Merge pull request #14933 from taosdata/test/last_row

test: add test case for last_row , only with case ,not run CI 
......@@ -425,8 +425,8 @@ class TDTestCase:
tdSql.checkRows(70)
tdSql.query("select csum(c1) from stb1 partition by tbname ")
tdSql.checkRows(40)
# tdSql.query("select csum(st1) from stb1 partition by tbname")
# tdSql.checkRows(70)
tdSql.query("select csum(st1) from stb1 partition by tbname")
tdSql.checkRows(70)
tdSql.query("select csum(st1+c1) from stb1 partition by tbname")
tdSql.checkRows(40)
tdSql.query("select csum(st1+c1) from stb1 partition by tbname")
......@@ -445,22 +445,22 @@ class TDTestCase:
tdSql.checkRows(40)
# bug need fix
# tdSql.query("select tbname , csum(c1) from stb1 partition by tbname")
# tdSql.checkRows(40)
# tdSql.query("select tbname , csum(st1) from stb1 partition by tbname")
# tdSql.checkRows(70)
# tdSql.query("select tbname , csum(st1) from stb1 partition by tbname slimit 1")
# tdSql.checkRows(7)
tdSql.query("select tbname , csum(c1) from stb1 partition by tbname")
tdSql.checkRows(40)
tdSql.query("select tbname , csum(st1) from stb1 partition by tbname")
tdSql.checkRows(70)
tdSql.query("select tbname , csum(st1) from stb1 partition by tbname slimit 1")
tdSql.checkRows(7)
# partition by tags
# tdSql.query("select st1 , csum(c1) from stb1 partition by st1")
# tdSql.checkRows(40)
# tdSql.query("select csum(c1) from stb1 partition by st1")
# tdSql.checkRows(40)
# tdSql.query("select st1 , csum(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(4)
# tdSql.query("select csum(c1) from stb1 partition by st1 slimit 1")
# tdSql.checkRows(4)
tdSql.query("select st1 , csum(c1) from stb1 partition by st1")
tdSql.checkRows(40)
tdSql.query("select csum(c1) from stb1 partition by st1")
tdSql.checkRows(40)
tdSql.query("select st1 , csum(c1) from stb1 partition by st1 slimit 1")
tdSql.checkRows(4)
tdSql.query("select csum(c1) from stb1 partition by st1 slimit 1")
tdSql.checkRows(4)
# partition by col
# tdSql.query("select c1 , csum(c1) from stb1 partition by c1")
......
此差异已折叠。
......@@ -45,8 +45,8 @@ class TDTestCase:
tdSql.query(" select max(c1) from stb group by tbname order by tbname ")
tdSql.checkRows(self.tb_nums)
# bug need fix
# tdSql.query(" select max(t1) from stb group by t2 order by t2 ")
# tdSql.checkRows(self.tb_nums)
tdSql.query(" select max(t2) from stb group by t2 order by t2 ")
tdSql.checkRows(self.tb_nums)
tdSql.query(" select max(c1) from stb group by c1 order by c1 ")
tdSql.checkRows(self.row_nums+1)
......@@ -90,8 +90,8 @@ class TDTestCase:
tdSql.query("select tbname , max(t2) from stb partition by t2 order by t2")
# # bug need fix
# tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2")
# tdSql.checkRows(self.tb_nums)
tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2")
tdSql.checkRows(self.tb_nums)
tdSql.query("select tbname , max(c1) from stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums)
......@@ -126,8 +126,8 @@ class TDTestCase:
tdSql.checkData(0,0,self.row_nums)
# bug need fix
# tdSql.query("select count(c1) , max(t1) ,abs(c1) from stb partition by abs(c1) order by abs(c1)")
# tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)")
tdSql.checkRows(self.row_nums+1)
tdSql.query("select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)")
......@@ -136,6 +136,18 @@ class TDTestCase:
tdSql.query("select max(ceil(c1-2)) , max(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))")
tdSql.checkRows(self.row_nums+1)
tdSql.query("select tbname , max(c1) ,c1 from stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,0,'sub_stb_0')
tdSql.checkData(0,1,9)
tdSql.checkData(0,2,9)
tdSql.query("select tbname ,top(c1,1) ,c1 from stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums)
tdSql.query(" select c1 , sample(c1,2) from stb partition by tbname order by tbname ")
tdSql.checkRows(self.tb_nums*2)
# interval
......
......@@ -31,6 +31,7 @@ class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
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=""):
'''
......@@ -624,10 +625,11 @@ class TDTestCase:
tdLog.info(" sample data is in datas groups ,successed sql is : %s" % sample_query )
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 300 ")
tdSql.execute(" create database if not exists db duration 300d ")
tdSql.execute(" use db ")
tdSql.execute(
'''create table stb1
......@@ -759,14 +761,6 @@ class TDTestCase:
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")
tdSql.query("select sample(c1,2) ,c2,c3 ,c5 from stb1")
tdSql.checkRows(2)
tdSql.checkCols(4)
self.check_sample("select sample( c1 ,3 ),c2,c3,c4,c5 from t1 where c1 between 1 and 10" ,"select c1,c2,c3,c4,c5 from t1 where c1 between 1 and 10")
self.check_sample("select sample( c1 ,3 ),c2,c3,c4,c5 from stb1 where c1 between 1 and 10" ,"select c1,c2,c3,c4,c5 from stb1 where c1 between 1 and 10")
self.check_sample("select sample( c1 ,3 ),t1 from stb1 where c1 between 1 and 10" ,"select c1,t1 from stb1 where c1 between 1 and 10")
# join
tdSql.query("select sample( ct4.c1 , 1 ) from ct1, ct4 where ct4.ts=ct1.ts")
......@@ -779,8 +773,8 @@ class TDTestCase:
self.check_sample("select sample(c1,2) from stb1 partition by tbname" , "select c1 from stb1 partition by tbname")
# nest query
tdSql.query("select sample(c1,2) from (select c1 from t1); ")
tdSql.checkRows(2)
# tdSql.query("select sample(c1,2) from (select c1 from t1); ")
# tdSql.checkRows(2)
# union all
tdSql.query("select sample(c1,2) from t1 union all select sample(c1,3) from t1")
......@@ -798,36 +792,6 @@ class TDTestCase:
tdSql.query("select sample(c1,100)+2 from ct1")
tdSql.query("select abs(sample(c1,100)) from ct1")
# support stable and tbname
tdSql.query("select tbname ,sample(c1,2) from stb1 partition by tbname order by tbname")
tdSql.checkRows(4)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(3,0,'ct4')
# # bug need fix
# tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(4)
# tdSql.checkData(0,0,'ct1')
# tdSql.checkData(3,0,'ct4')
# tdSql.checkData(0,2,1)
# tdSql.checkData(3,2,4)
tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by t1 order by t1 ")
tdSql.checkRows(4)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(3,0,'ct4')
tdSql.checkData(0,2,1)
tdSql.checkData(3,2,4)
# bug need fix
# tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by c1 order by c1 ")
# tdSql.checkRows(21)
# bug need fix
# tdSql.query(" select sample(c1,2) from stb1 partition by c1 ")
# tdSql.checkRows(21)
def sample_test_run(self) :
tdLog.printNoPrefix("==========support sample function==========")
tbnum = 10
......@@ -891,11 +855,29 @@ class TDTestCase:
self.basic_sample_query()
def sample_big_data(self):
tdSql.execute("create database sample_db")
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)")
for i in range(2000):
ts = self.ts+i*10
tdSql.execute(f"insert into sub_tb values({ts} ,{i})")
tdSql.query("select count(*) from st")
tdSql.checkData(0,0,2000)
tdSql.query("select sample(c1 ,1000) from st")
tdSql.checkRows(1000)
def run(self):
import traceback
try:
# run in develop branch
self.sample_test_run()
self.sample_big_data()
pass
except Exception as e:
traceback.print_exc()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册