Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
686ab4f5
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
686ab4f5
编写于
7月 01, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test cases
上级
870fbd46
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
78 deletion
+76
-78
tests/system-test/2-query/function_stateduration.py
tests/system-test/2-query/function_stateduration.py
+33
-34
tests/system-test/2-query/statecount.py
tests/system-test/2-query/statecount.py
+43
-44
未找到文件。
tests/system-test/2-query/function_stateduration.py
浏览文件 @
686ab4f5
...
...
@@ -18,7 +18,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
prepare_datas
(
self
):
tdSql
.
execute
(
'''create table stb1
...
...
@@ -26,7 +26,7 @@ class TDTestCase:
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
...
...
@@ -68,7 +68,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def
test_errors
(
self
):
error_sql_lists
=
[
# "select stateduration(c1,'GT',5,1s) from t1"
...
...
@@ -110,35 +110,35 @@ class TDTestCase:
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
pass
def
support_types
(
self
):
other_no_value_types
=
[
"select stateduration(ts,'GT',1,1s) from t1"
,
"select stateduration(ts,'GT',1,1s) from t1"
,
"select stateduration(c7,'GT',1,1s) from t1"
,
"select stateduration(c8,'GT',1,1s) from t1"
,
"select stateduration(c9,'GT',1,1s) from t1"
,
"select stateduration(ts,'GT',1,1s) from ct1"
,
"select stateduration(ts,'GT',1,1s) from ct1"
,
"select stateduration(c7,'GT',1,1s) from ct1"
,
"select stateduration(c8,'GT',1,1s) from ct1"
,
"select stateduration(c9,'GT',1,1s) from ct1"
,
"select stateduration(ts,'GT',1,1s) from ct3"
,
"select stateduration(ts,'GT',1,1s) from ct3"
,
"select stateduration(c7,'GT',1,1s) from ct3"
,
"select stateduration(c8,'GT',1,1s) from ct3"
,
"select stateduration(c9,'GT',1,1s) from ct3"
,
"select stateduration(ts,'GT',1,1s) from ct4"
,
"select stateduration(ts,'GT',1,1s) from ct4"
,
"select stateduration(c7,'GT',1,1s) from ct4"
,
"select stateduration(c8,'GT',1,1s) from ct4"
,
"select stateduration(c9,'GT',1,1s) from ct4"
,
"select stateduration(ts,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(ts,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c7,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c8,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c9,'GT',1,1s) from stb1 partition by tbname"
"select stateduration(c9,'GT',1,1s) from stb1 partition by tbname"
]
for
type_sql
in
other_no_value_types
:
tdSql
.
error
(
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
type_sql_lists
=
[
"select stateduration(c1,'GT',1,1s) from t1"
,
"select stateduration(c2,'GT',1,1s) from t1"
,
...
...
@@ -168,8 +168,8 @@ class TDTestCase:
"select stateduration(c5,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) as alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) as alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) alisb from stb1 partition by tbname"
,
]
for
type_sql
in
type_sql_lists
:
...
...
@@ -177,7 +177,7 @@ class TDTestCase:
def
support_opers
(
self
):
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
for
oper
in
oper_lists
:
...
...
@@ -190,7 +190,7 @@ class TDTestCase:
def
basic_stateduration_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
...
...
@@ -211,9 +211,9 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from ct3"
)
# will support _rowts mix with
# will support _rowts mix with
# tdSql.query("select (c6,'GT',1,1s),_rowts from ct3")
# auto check for t1 table
# used for regular table
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from t1"
)
...
...
@@ -229,17 +229,17 @@ class TDTestCase:
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),tbname from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),t1 from ct1"
)
# unique with common col
# unique with common col
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,ts from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,c1 from ct1"
)
# unique with scalar function
# unique with scalar function
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , unique(c2) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , abs(c2)+2 from ct1"
)
# unique with aggregate function
# unique with aggregate function
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,max(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,csum(c1) from ct1"
)
...
...
@@ -262,16 +262,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
1
,
0
,
6134400
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
# unique with union all
# unique with union all
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select stateduration(c1,'GT',1,1s) from ct1"
)
tdSql
.
checkRows
(
25
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
checkRows
(
22
)
# unique with join
# prepare join datas with same ts
# unique with join
# prepare join datas with same ts
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
...
...
@@ -328,7 +328,7 @@ class TDTestCase:
tdSql
.
checkRows
(
12
)
tdSql
.
query
(
"select stateduration(c1+2 ,'GT',1,1s) from t1"
)
tdSql
.
checkRows
(
12
)
# bug for stable
#partition by tbname
...
...
@@ -337,21 +337,20 @@ class TDTestCase:
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.checkRows(21)
# group by
# group by
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by c1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by tbname"
)
# super table
def
check_unit_time
(
self
):
tdSql
.
execute
(
" use db "
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
1000
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
...
...
@@ -360,8 +359,8 @@ class TDTestCase:
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
...
tests/system-test/2-query/statecount.py
浏览文件 @
686ab4f5
...
...
@@ -18,7 +18,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
prepare_datas
(
self
):
tdSql
.
execute
(
'''create table stb1
...
...
@@ -26,7 +26,7 @@ class TDTestCase:
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
...
...
@@ -68,7 +68,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def
test_errors
(
self
):
error_sql_lists
=
[
# "select statecount(c1,'GT',5) from t1"
...
...
@@ -110,35 +110,35 @@ class TDTestCase:
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
pass
def
support_types
(
self
):
other_no_value_types
=
[
"select statecount(ts,'GT',1) from t1"
,
"select statecount(ts,'GT',1) from t1"
,
"select statecount(c7,'GT',1) from t1"
,
"select statecount(c8,'GT',1) from t1"
,
"select statecount(c9,'GT',1) from t1"
,
"select statecount(ts,'GT',1) from ct1"
,
"select statecount(ts,'GT',1) from ct1"
,
"select statecount(c7,'GT',1) from ct1"
,
"select statecount(c8,'GT',1) from ct1"
,
"select statecount(c9,'GT',1) from ct1"
,
"select statecount(ts,'GT',1) from ct3"
,
"select statecount(ts,'GT',1) from ct3"
,
"select statecount(c7,'GT',1) from ct3"
,
"select statecount(c8,'GT',1) from ct3"
,
"select statecount(c9,'GT',1) from ct3"
,
"select statecount(ts,'GT',1) from ct4"
,
"select statecount(ts,'GT',1) from ct4"
,
"select statecount(c7,'GT',1) from ct4"
,
"select statecount(c8,'GT',1) from ct4"
,
"select statecount(c9,'GT',1) from ct4"
,
"select statecount(ts,'GT',1) from stb1 partition by tbname"
,
"select statecount(ts,'GT',1) from stb1 partition by tbname"
,
"select statecount(c7,'GT',1) from stb1 partition by tbname"
,
"select statecount(c8,'GT',1) from stb1 partition by tbname"
,
"select statecount(c9,'GT',1) from stb1 partition by tbname"
"select statecount(c9,'GT',1) from stb1 partition by tbname"
]
for
type_sql
in
other_no_value_types
:
tdSql
.
error
(
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
type_sql_lists
=
[
"select statecount(c1,'GT',1) from t1"
,
"select statecount(c2,'GT',1) from t1"
,
...
...
@@ -168,8 +168,8 @@ class TDTestCase:
"select statecount(c5,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) as alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) as alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) alisb from stb1 partition by tbname"
,
]
for
type_sql
in
type_sql_lists
:
...
...
@@ -177,7 +177,7 @@ class TDTestCase:
def
support_opers
(
self
):
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
for
oper
in
oper_lists
:
...
...
@@ -190,7 +190,7 @@ class TDTestCase:
def
basic_statecount_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
...
...
@@ -211,9 +211,9 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select statecount(c6,'GT',1) from ct3"
)
# will support _rowts mix with
# will support _rowts mix with
# tdSql.query("select (c6,'GT',1),_rowts from ct3")
# auto check for t1 table
# used for regular table
tdSql
.
query
(
"select statecount(c6,'GT',1) from t1"
)
...
...
@@ -229,17 +229,17 @@ class TDTestCase:
tdSql
.
error
(
"select statecount(c6,'GT',1),tbname from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1),t1 from ct1"
)
# unique with common col
# unique with common col
tdSql
.
error
(
"select statecount(c6,'GT',1) ,ts from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,c1 from ct1"
)
# unique with scalar function
# unique with scalar function
tdSql
.
error
(
"select statecount(c6,'GT',1) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , unique(c2) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , abs(c2)+2 from ct1"
)
# unique with aggregate function
# unique with aggregate function
tdSql
.
error
(
"select statecount(c6,'GT',1) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,max(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,csum(c1) from ct1"
)
...
...
@@ -262,16 +262,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
# unique with union all
# unique with union all
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select statecount(c1,'GT',1) from ct1"
)
tdSql
.
checkRows
(
25
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
checkRows
(
22
)
# unique with join
# prepare join datas with same ts
# unique with join
# prepare join datas with same ts
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
...
...
@@ -323,7 +323,7 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
3
,
0
,
-
1.000000000
)
# bug for stable
#partition by tbname
...
...
@@ -332,21 +332,20 @@ class TDTestCase:
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.checkRows(21)
# group by
# group by
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct1 group by c1"
)
tdSql
.
error
(
"select statecount(c1,'GT',1) from ct1 group by tbname"
)
# super table
def
check_unit_time
(
self
):
tdSql
.
execute
(
" use db "
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
1000
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
...
...
@@ -355,8 +354,8 @@ class TDTestCase:
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
...
@@ -384,11 +383,11 @@ class TDTestCase:
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() )"
)
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() )"
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from sub1_bound"
)
tdSql
.
checkRows
(
5
)
...
...
@@ -396,29 +395,29 @@ class TDTestCase:
tdSql
.
prepare
()
tdLog
.
printNoPrefix
(
"==========step1:create table =============="
)
self
.
prepare_datas
()
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
self
.
test_errors
()
tdLog
.
printNoPrefix
(
"==========step3:support types ============"
)
tdLog
.
printNoPrefix
(
"==========step3:support types ============"
)
self
.
support_types
()
tdLog
.
printNoPrefix
(
"==========step4:support opers ============"
)
tdLog
.
printNoPrefix
(
"==========step4:support opers ============"
)
self
.
support_opers
()
tdLog
.
printNoPrefix
(
"==========step5: statecount basic query ============"
)
tdLog
.
printNoPrefix
(
"==========step5: statecount basic query ============"
)
self
.
basic_statecount_function
()
tdLog
.
printNoPrefix
(
"==========step6: statecount boundary query ============"
)
tdLog
.
printNoPrefix
(
"==========step6: statecount boundary query ============"
)
self
.
check_boundary_values
()
tdLog
.
printNoPrefix
(
"==========step6: statecount unit time test ============"
)
tdLog
.
printNoPrefix
(
"==========step6: statecount unit time test ============"
)
self
.
check_unit_time
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录