Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f0b6e00
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2f0b6e00
编写于
7月 16, 2022
作者:
W
wenzhouwww@live.cn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test case for last_row
上级
98178c60
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
107 addition
and
92 deletion
+107
-92
tests/system-test/2-query/last_row.py
tests/system-test/2-query/last_row.py
+107
-92
未找到文件。
tests/system-test/2-query/last_row.py
浏览文件 @
2f0b6e00
...
...
@@ -216,16 +216,11 @@ class TDTestCase:
tdSql
.
execute
(
"use testdb"
)
# bug need fix
# tdSql.query
("select last_row(c1 ,NULL) from t1")
tdSql
.
error
(
"select last_row(c1 ,NULL) from t1"
)
error_sql_lists
=
[
"select last_row from t1"
,
"select last_row(-+--+c1) from t1"
,
# "select +-last_row(c1) from t1",
# "select ++-last_row(c1) from t1",
# "select ++--last_row(c1) from t1",
# "select - -last_row(c1)*0 from t1",
# "select last_row(tbname+1) from t1 ",
"select last_row(123--123)==1 from t1"
,
"select last_row(c1) as 'd1' from t1"
,
"select last_row(c1 ,NULL) from t1"
,
...
...
@@ -233,15 +228,8 @@ class TDTestCase:
"select last_row(abs(c1) ab from t1)"
,
"select last_row(c1) as int from t1"
,
"select last_row from stb1"
,
# "select last_row(-+--+c1) from stb1",
# "select +-last_row(c1) from stb1",
# "select ++-last_row(c1) from stb1",
# "select ++--last_row(c1) from stb1",
# "select - -last_row(c1)*0 from stb1",
# "select last_row(tbname+1) from stb1 ",
"select last_row(123--123)==1 from stb1"
,
"select last_row(c1) as 'd1' from stb1"
,
# "select last_row(c1 ,c2 ) from stb1",
"select last_row(c1 ,NULL) from stb1"
,
"select last_row(,) from stb1;"
,
"select last_row(abs(c1) ab from stb1)"
,
...
...
@@ -313,12 +301,12 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
4
,
-
9.99000
)
# bug need fix
#
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from stb1 where tbname='ct1'")
#
tdSql.checkData(0, 0, 9)
#
tdSql.checkData(0, 1, -99999)
#
tdSql.checkData(0, 2, -999)
#
tdSql.checkData(0, 3, None)
#
tdSql.checkData(0, 4,-9.99000)
tdSql
.
query
(
"select last_row(c1), c2, c3 , c4, c5 from stb1 where tbname='ct1'"
)
tdSql
.
checkData
(
0
,
0
,
9
)
tdSql
.
checkData
(
0
,
1
,
-
99999
)
tdSql
.
checkData
(
0
,
2
,
-
999
)
tdSql
.
checkData
(
0
,
3
,
None
)
tdSql
.
checkData
(
0
,
4
,
-
9.99000
)
# bug fix
tdSql
.
query
(
"select last_row(abs(c1)) from ct1"
)
...
...
@@ -342,13 +330,13 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
2
,
None
)
# tdSql.query("select last_row(c1 ,c2 ,c3) ,last_row(c4) from stb1 where ts <now")
# tdSql.query("select last_row(c1 ,c2 ,c3) ,last_row(c4) from stb1 where ts <now
-1d
")
# tdSql.checkData(0,0,9)
# tdSql.checkData(0,1,-99999)
# tdSql.checkData(0,2,-999)
# tdSql.checkData(0,3,None)
# tdSql.query("select last_row(c1 ,c2 ,c3 ,c4) ,last(c4) from stb1 where ts <now")
# tdSql.query("select last_row(c1 ,c2 ,c3 ,c4) ,last(c4) from stb1 where ts <now
-1d
")
# tdSql.checkData(0,0,9)
# tdSql.checkData(0,1,-99999)
# tdSql.checkData(0,2,-999)
...
...
@@ -356,13 +344,13 @@ class TDTestCase:
# tdSql.checkData(0,4,-99)
# bug need fix
#
tdSql.query("select abs(last_row(c1)-2)+max(c1),ceil(last_row(c4)-2) from stb1 where c4 is not null")
#
tdSql.checkData(0,0,16.000000000)
#
tdSql.checkData(0,1,-101.000000000)
tdSql
.
query
(
"select abs(last_row(c1)-2)+max(c1),ceil(last_row(c4)-2) from stb1 where c4 is not null"
)
tdSql
.
checkData
(
0
,
0
,
16.000000000
)
tdSql
.
checkData
(
0
,
1
,
-
101.000000000
)
#
tdSql.query("select abs(last_row(c1)-2)+max(c1),ceil(last_row(c4)-2) from ct1 where c4<0")
#
tdSql.checkData(0,0,16.000000000)
#
tdSql.checkData(0,1,-101.000000000)
tdSql
.
query
(
"select abs(last_row(c1)-2)+max(c1),ceil(last_row(c4)-2) from ct1 where c4<0"
)
tdSql
.
checkData
(
0
,
0
,
16.000000000
)
tdSql
.
checkData
(
0
,
1
,
-
101.000000000
)
tdSql
.
query
(
"select last_row(ceil(c1+2)+floor(c1)-10) from stb1"
)
tdSql
.
checkData
(
0
,
0
,
None
)
...
...
@@ -373,30 +361,43 @@ class TDTestCase:
# filter for last_row
# bug need fix
# tdSql.query("select last_row(ts ,c1 ) from stb1 where ts < now ")
# tdSql.query("select last_row(ts ,c1 ) from stb1 where ts < now
-1d
")
# tdSql.checkData(0,1,9)
# tdSql.query("select last_row(ts ,c1 ) from ct4 where ts < now ")
# tdSql.query("select last_row(ts ,c1 ) from ct4 where ts < now
-1d
")
# tdSql.checkData(0,1,9)
# bug need fix for all function
#
tdSql.query("select last_row(ts ,c1 ) from ct4 where t1 = 1 ")
#
tdSql.checkRows(0)
tdSql
.
query
(
"select last_row(ts ,c1 ) from ct4 where t1 = 1 "
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select count(c1) from ct4 where t1 = 1 "
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last_row(c1) ,last(c1) from stb1 where c1 is null"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select last_row(c1) ,count(*) from stb1 where c1 is null"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
3
)
tdSql
.
query
(
"select last_row(c1) ,count(c1) from stb1 where c1 is null"
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
0
)
# bug need fix
#
tdSql.query("select tbname ,last_row(c1) from stb1")
#
tdSql.checkData(0,0,'ct4')
#
tdSql.checkData(0,1,None)
tdSql
.
query
(
"select tbname ,last_row(c1) from stb1"
)
tdSql
.
checkData
(
0
,
0
,
'ct4'
)
tdSql
.
checkData
(
0
,
1
,
None
)
#
tdSql.query(" select tbname ,last_row(c1) from stb1 partition by tbname order by tbname ")
#
tdSql.checkData(0,0,'ct1')
#
tdSql.checkData(0,1,9)
#
tdSql.checkData(1,0,'ct4')
#
tdSql.checkData(1,1,None)
tdSql
.
query
(
" select tbname ,last_row(c1) from stb1 partition by tbname order by tbname "
)
tdSql
.
checkData
(
0
,
0
,
'ct1'
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
0
,
'ct4'
)
tdSql
.
checkData
(
1
,
1
,
None
)
tdSql
.
query
(
" select tbname ,last_row(c1) from stb1 group by tbname order by tbname "
)
tdSql
.
checkData
(
0
,
0
,
'ct1'
)
...
...
@@ -408,17 +409,17 @@ class TDTestCase:
tdSql
.
checkRows
(
2
)
# filter by tbname
#
tdSql.query("select last_row(c1) from stb1 where tbname = 'ct1' ")
#
tdSql.checkData(0,0,9)
tdSql
.
query
(
"select last_row(c1) from stb1 where tbname = 'ct1' "
)
tdSql
.
checkData
(
0
,
0
,
9
)
# bug need fix
#
tdSql.query("select tbname ,last_row(c1) from stb1 where tbname = 'ct1' ")
# tdSql.checkData(0,0
,9)
#
tdSql.query("select tbname ,last_row(c1) from stb1 partition by tbname order by tbname")
#
tdSql.checkData(0, 0, 'ct1')
#
tdSql.checkData(0, 1, 9)
#
tdSql.checkData(1, 0, 'ct4')
#
tdSql.checkData(1, 1, None)
tdSql
.
query
(
"select tbname ,last_row(c1) from stb1 where tbname = 'ct1' "
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
query
(
"select tbname ,last_row(c1) from stb1 partition by tbname order by tbname"
)
tdSql
.
checkData
(
0
,
0
,
'ct1'
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
0
,
'ct4'
)
tdSql
.
checkData
(
1
,
1
,
None
)
tdSql
.
query
(
"select tbname ,last_row(c1) from stb1 group by tbname order by tbname"
)
tdSql
.
checkData
(
0
,
0
,
'ct1'
)
...
...
@@ -439,22 +440,21 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
2
,
333
)
tdSql
.
checkData
(
0
,
3
,
3
)
# filter by tag
# tdSql.query("select tbname ,last_row(c1) from stb1 where t1 =1
")
# tdSql.checkData(0,0
,9)
#
tdSql.query("select tbname ,last_row(c1) ,t1 from stb1 partition by t1 order by t1")
#
tdSql.checkData(0, 0, 'ct1')
#
tdSql.checkData(0, 1, 9)
#
tdSql.checkData(1, 0, 'ct4')
#
tdSql.checkData(1, 1, None)
tdSql
.
query
(
"select tbname ,last_row(c1) from testdb.stb1 where t1 =0
"
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
query
(
"select tbname ,last_row(c1) ,t1 from stb1 partition by t1 order by t1"
)
tdSql
.
checkData
(
0
,
0
,
'ct1'
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
0
,
'ct4'
)
tdSql
.
checkData
(
1
,
1
,
None
)
# filter by col
#
tdSql.query("select tbname ,last_row(c1),abs(c1)from stb1 where c1 =1;")
#
tdSql.checkData(0, 0, 'ct1')
#
tdSql.checkData(0, 1, 1)
#
tdSql.checkData(0, 2, 1)
tdSql
.
query
(
"select tbname ,last_row(c1),abs(c1)from stb1 where c1 =1;"
)
tdSql
.
checkData
(
0
,
0
,
'ct1'
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
query
(
"select last_row(c1) from stb1 where abs(ceil(c1))*c1==1"
)
tdSql
.
checkData
(
0
,
0
,
1
)
...
...
@@ -470,8 +470,8 @@ class TDTestCase:
tdSql
.
query
(
"select last(c1), max(c1+abs(c1)),last_row(c1+abs(c1)) from stb1 partition by tbname order by tbname"
)
# # bug need fix ,taosd crash
# tdSql.query
("select last_row(*) ,last(*) from stb1 partition by tbname order by last(*)")
# tdSql.query
("select last_row(*) ,last(*) from stb1 partition by tbname order by last_row(*)")
tdSql
.
error
(
"select last_row(*) ,last(*) from stb1 partition by tbname order by last(*)"
)
tdSql
.
error
(
"select last_row(*) ,last(*) from stb1 partition by tbname order by last_row(*)"
)
# mix with agg functions
tdSql
.
query
(
"select last(*), last_row(*),last(c1), last_row(c1) from stb1 "
)
...
...
@@ -489,7 +489,7 @@ class TDTestCase:
# bug fix for compute
tdSql
.
query
(
"select last_row(c1) -0 ,last(c1)-0 ,last(c1)+last_row(c1) from ct4 "
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
1
,
0.000000000
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
query
(
" select c1, abs(c1) -0 ,last_row(c1-0.1)-0.1 from ct1"
)
...
...
@@ -581,9 +581,9 @@ class TDTestCase:
tdSql
.
query
(
"select last_row(c1,t1) from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
3
)
#
tdSql.query("select last_row(c1),t1 from stb1 ")
#
tdSql.checkData(0,0,None)
#
tdSql.checkData(0,1,3)
tdSql
.
query
(
"select last_row(c1),t1 from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
3
)
tdSql
.
query
(
"select last_row(c1,t1),last(t1) from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
3
)
...
...
@@ -600,36 +600,38 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
# nest query for last_row
# tdSql.query("select last_row(t1) from (select c1 ,t1 from stb1)")
# tdSql.checkData(0,0,
61
)
# tdSql.query("select last_row(t1) from (select
ts ,
c1 ,t1 from stb1)")
# tdSql.checkData(0,0,
4
)
# tdSql.query("select distinct(c1) ,t1 from stb1")
# tdSql.checkRows(20)
tdSql
.
query
(
"select last_row(c1) from (select _rowts , c1 ,t1 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
None
)
#
tdSql.query("select last_row(c1) from (select _rowts , c1 ,t1 from stb1)")
#
tdSql.checkData(0,0,None)
tdSql
.
query
(
"select last_row(c1) from (select ts , c1 ,t1 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
None
)
#
tdSql.query("select last_row(c1) from (select ts , c1 ,t1 from stb1)")
#
tdSql.checkData(0,0,None)
tdSql
.
query
(
"select ts , last_row(c1) ,c1 from (select ts , c1 ,t1 from stb1)"
)
tdSql
.
checkData
(
0
,
1
,
None
,
None
)
#
tdSql.query("select ts , last_row(c1) ,c1 from (select ts , c1 ,t1 from stb1)")
#
tdSql.checkData(0,1,None,None)
tdSql
.
query
(
"select ts , last_row(c1) ,c1 from (select ts , max(c1) c1 ,t1 from stb1 where ts >now -1h and ts <now interval(10s) fill(value ,10 ))"
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
checkData
(
0
,
1
,
10
)
#
tdSql.query("select ts , last_row(c1) ,c1 from (select ts , max(c1) c1 ,t1 from stb1 where ts >now -1h and ts <now interval(10s) fill(value ,10 ))")
#
tdSql.checkData(0,1,10)
#
tdSql.checkData(0,1,10)
tdSql
.
query
(
"select ts , last_row(c1) ,c1 from (select count(c1) c1 from stb1 where ts >now -1h and ts <now interval(10s) fill(value ,10 ))"
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
checkData
(
0
,
1
,
10
)
#
tdSql.query("select ts , last_row(c1) ,c1 from (select count(c1) c1 from stb1 where ts >now -1h and ts <now interval(10s) fill(value ,10 ))")
#
tdSql.checkData(0,1,10)
#
tdSql.checkData(0,1,10)
tdSql
.
error
(
"select last_row(c1) ,c1 from (select count(c1) c1 from stb1 where ts >now -1h and ts <now interval(10s) fill(value ,10 ))"
)
#
tdSql.error("select last_row(c1) ,c1 from (select count(c1) c1 from stb1 where ts >now -1h and ts <now interval(10s) fill(value ,10 ))")
# tag filter with last_row function
tdSql
.
query
(
"select last_row(t1) from stb1 where abs(t1)=1"
)
tdSql
.
query
(
"select last_row(t1) from testdb.stb1 where abs(t1)=1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last_row(t1) from testdb.stb1 where abs(t1)=0"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
" select last_row(t1),last_row(c1) from ct1 where abs(c1+t1)=1"
)
tdSql
.
query
(
" select last_row(t1),last_row(c1) from
db.
ct1 where abs(c1+t1)=1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
0
,
1
,
0
)
tdSql
.
query
(
"select last_row(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1"
)
...
...
@@ -640,8 +642,19 @@ class TDTestCase:
tdSql
.
checkRows
(
2
)
# bug need fix
# tdSql.query("select last_row(c1) from testdb.stb1 group by c1 order by t1 ")
# tdSql.query("select last_row(c1) from db.stb1 group by c1 order by t1 ")
tdSql
.
query
(
"select last_row(c1) from testdb.stb1 group by c1 order by c1,t1 "
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
9
,
0
,
8
)
tdSql
.
query
(
"select last_row(c1) from db.stb1 group by c1 order by t1 "
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
4
)
tdSql
.
query
(
"select last_row(c1) from stb1 group by c1 order by t1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
query
(
"select last_row(c1) from stb1 group by c1 order by c1,t1;"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
9
)
# bug need fix , result is error
tdSql
.
query
(
"select last_row(c1) from ct4 group by c1 order by t1 "
)
...
...
@@ -666,6 +679,8 @@ class TDTestCase:
tdSql
.
checkRows
(
11
)
tdSql
.
query
(
"select last_row(c1+c3)+last_row(c2) from stb1 group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
2
,
0
,
11223.000000000
)
tdSql
.
query
(
"select last_row(t1) from stb1 where abs(c1+t1)=1 partition by tbname"
)
tdSql
.
checkData
(
0
,
0
,
1
)
...
...
@@ -685,13 +700,13 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
3
,
None
)
# bug need fix
#
tdSql.query("select tbname , last_row(c1) from stb1 partition by c2 order by c1")
#
tdSql.checkRows(11)
#
tdSql.checkData(10,1,9)
tdSql
.
query
(
"select tbname , last_row(c1) from stb1 partition by c2 order by c1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
1
,
9
)
#
tdSql.query("select tbname , last_row(c1) from stb1 partition by c2 order by c2")
#
tdSql.checkRows(11)
#
tdSql.checkData(10,1,88888)
tdSql
.
query
(
"select tbname , last_row(c1) from stb1 partition by c2 order by c2"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
1
,
88888
)
tdSql
.
query
(
"select tbname , last_row(t1) from stb1 partition by c2 order by t1"
)
tdSql
.
checkRows
(
11
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录