Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa9761ce
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看板
提交
aa9761ce
编写于
7月 05, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test case white spaces
上级
9ef0497e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
46 deletion
+46
-46
tests/system-test/2-query/avg.py
tests/system-test/2-query/avg.py
+46
-46
未找到文件。
tests/system-test/2-query/avg.py
浏览文件 @
aa9761ce
...
...
@@ -14,7 +14,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
True
)
def
prepare_datas
(
self
):
tdSql
.
execute
(
'''create table stb1
...
...
@@ -22,7 +22,7 @@ class TDTestCase:
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
...
...
@@ -64,7 +64,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
def
check_avg
(
self
,
origin_query
,
check_query
):
avg_result
=
tdSql
.
getResult
(
origin_query
)
origin_result
=
tdSql
.
getResult
(
check_query
)
...
...
@@ -73,13 +73,13 @@ class TDTestCase:
for
row_index
,
row
in
enumerate
(
avg_result
):
for
col_index
,
elem
in
enumerate
(
row
):
if
avg_result
[
row_index
][
col_index
]
!=
origin_result
[
row_index
][
col_index
]:
check_status
=
False
check_status
=
False
if
not
check_status
:
tdLog
.
notice
(
"avg function value has not as expected , sql is
\"
%s
\"
"
%
origin_query
)
sys
.
exit
(
1
)
else
:
tdLog
.
info
(
"avg value check pass , it work as expected ,sql is
\"
%s
\"
"
%
check_query
)
def
test_errors
(
self
):
error_sql_lists
=
[
"select avg from t1"
,
...
...
@@ -113,42 +113,42 @@ class TDTestCase:
]
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
def
support_types
(
self
):
type_error_sql_lists
=
[
"select avg(ts) from t1"
,
"select avg(ts) from t1"
,
"select avg(c7) from t1"
,
"select avg(c8) from t1"
,
"select avg(c9) from t1"
,
"select avg(ts) from ct1"
,
"select avg(ts) from ct1"
,
"select avg(c7) from ct1"
,
"select avg(c8) from ct1"
,
"select avg(c9) from ct1"
,
"select avg(ts) from ct3"
,
"select avg(ts) from ct3"
,
"select avg(c7) from ct3"
,
"select avg(c8) from ct3"
,
"select avg(c9) from ct3"
,
"select avg(ts) from ct4"
,
"select avg(ts) from ct4"
,
"select avg(c7) from ct4"
,
"select avg(c8) from ct4"
,
"select avg(c9) from ct4"
,
"select avg(ts) from stb1"
,
"select avg(ts) from stb1"
,
"select avg(c7) from stb1"
,
"select avg(c8) from stb1"
,
"select avg(c9) from stb1"
,
"select avg(ts) from stbbb1"
,
"select avg(ts) from stbbb1"
,
"select avg(c7) from stbbb1"
,
"select avg(ts) from tbname"
,
"select avg(c9) from tbname"
]
for
type_sql
in
type_error_sql_lists
:
tdSql
.
error
(
type_sql
)
type_sql_lists
=
[
"select avg(c1) from t1"
,
"select avg(c2) from t1"
,
...
...
@@ -178,16 +178,16 @@ class TDTestCase:
"select avg(c5) from stb1"
,
"select avg(c6) from stb1"
,
"select avg(c6) as alisb from stb1"
,
"select avg(c6) alisb from stb1"
,
"select avg(c6) as alisb from stb1"
,
"select avg(c6) alisb from stb1"
,
]
for
type_sql
in
type_sql_lists
:
tdSql
.
query
(
type_sql
)
def
basic_avg_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
...
...
@@ -207,18 +207,18 @@ class TDTestCase:
tdSql
.
query
(
"select avg(c5) from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select avg(c6) from ct3"
)
# used for regular table
tdSql
.
query
(
"select avg(c1) from t1"
)
tdSql
.
checkData
(
0
,
0
,
5.000000000
)
tdSql
.
query
(
"select ts,c1, c2, c3 , c4, c5 from t1"
)
tdSql
.
checkData
(
1
,
5
,
1.11000
)
tdSql
.
checkData
(
3
,
4
,
33
)
tdSql
.
checkData
(
5
,
5
,
None
)
self
.
check_avg
(
" select avg(c1) , avg(c2) , avg(c3) from t1 "
,
" select sum(c1)/count(c1) , sum(c2)/count(c2) , sum(c3)/count(c3) from t1 "
)
# used for sub table
tdSql
.
query
(
"select avg(c1) from ct1"
)
tdSql
.
checkData
(
0
,
0
,
4.846153846
)
...
...
@@ -229,8 +229,8 @@ class TDTestCase:
self
.
check_avg
(
" select avg(abs(c1)) , avg(abs(c2)) , avg(abs(c3)) from t1 "
,
" select sum(abs(c1))/count(c1) , sum(abs(c2))/count(c2) , sum(abs(c3))/count(c3) from t1 "
)
self
.
check_avg
(
" select avg(abs(c1)) , avg(abs(c2)) , avg(abs(c3)) from stb1 "
,
" select sum(abs(c1))/count(c1) , sum(abs(c2))/count(c2) , sum(abs(c3))/count(c3) from stb1 "
)
# used for stable table
# used for stable table
tdSql
.
query
(
"select avg(c1) from stb1"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -241,10 +241,10 @@ class TDTestCase:
tdSql
.
error
(
"select avg(c1) from tbname"
)
tdSql
.
error
(
"select avg(c1) from ct5"
)
# mix with common col
# mix with common col
tdSql
.
error
(
"select c1, avg(c1) from ct1"
)
tdSql
.
error
(
"select c1, avg(c1) from ct4"
)
# mix with common functions
tdSql
.
error
(
"select c1, avg(c1),c5, floor(c5) from ct4 "
)
...
...
@@ -278,11 +278,11 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
25
)
# bug fix for compute
# bug fix for compute
tdSql
.
error
(
"select c1, avg(c1) -0 ,ceil(c1)-0 from ct4 "
)
tdSql
.
error
(
" select c1, avg(c1) -0 ,avg(ceil(c1-0.1))-0.1 from ct4"
)
# mix with nest query
# mix with nest query
self
.
check_avg
(
"select avg(col) from (select abs(c1) col from stb1)"
,
"select avg(abs(c1)) from stb1"
)
self
.
check_avg
(
"select avg(col) from (select ceil(abs(c1)) col from stb1)"
,
"select avg(abs(c1)) from stb1"
)
...
...
@@ -297,7 +297,7 @@ class TDTestCase:
tdSql
.
query
(
" select avg(c1) from stb1 where c1 is null "
)
tdSql
.
checkRows
(
0
)
def
avg_func_filter
(
self
):
tdSql
.
execute
(
"use db"
)
tdSql
.
query
(
" select avg(c1), avg(c1) -0 ,avg(ceil(c1-0.1))-0 ,avg(floor(c1+0.1))-0.1 ,avg(ceil(log(c1,2)-0.5)) from ct4 where c1>5 "
)
...
...
@@ -324,7 +324,7 @@ class TDTestCase:
def
avg_Arithmetic
(
self
):
pass
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
...
@@ -344,11 +344,11 @@ class TDTestCase:
tdSql
.
execute
(
f
"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql
.
execute
(
f
"insert into sub1_bound values ( now(), 2147483645, 9223372036854775805, 32765, 125, 3.40E+37, 1.7e+307, True, 'binary_tb1', 'nchar_tb1', now() )"
)
tdSql
.
execute
(
f
"insert into sub1_bound values ( now(), 2147483644, 9223372036854775804, 32764, 124, 3.40E+37, 1.7e+307, True, 'binary_tb1', 'nchar_tb1', now() )"
)
...
...
@@ -359,14 +359,14 @@ class TDTestCase:
tdSql
.
execute
(
f
"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+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() )"
)
self
.
check_avg
(
"select avg(c1), avg(c2), avg(c3) , avg(c4), avg(c5) ,avg(c6) from sub1_bound "
,
" select sum(c1)/count(c1), sum(c2)/count(c2) ,sum(c3)/count(c3), sum(c4)/count(c4), sum(c5)/count(c5) ,sum(c6)/count(c6) from sub1_bound "
)
# check basic elem for table per row
tdSql
.
query
(
"select avg(c1) ,avg(c2) , avg(c3) , avg(c4), avg(c5), avg(c6) from sub1_bound "
)
tdSql
.
checkRows
(
1
)
...
...
@@ -376,8 +376,8 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
3
,
53.571428571
)
tdSql
.
checkData
(
0
,
4
,
5.828571332045761e+37
)
# tdSql.checkData(0,5,None)
# check + - * / in functions
tdSql
.
query
(
" select avg(c1+1) ,avg(c2) , avg(c3*1) , avg(c4/2), avg(c5)/2, avg(c6) from sub1_bound "
)
tdSql
.
checkData
(
0
,
0
,
920350134.5714285
)
...
...
@@ -386,33 +386,33 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
3
,
26.785714286
)
tdSql
.
checkData
(
0
,
4
,
2.9142856660228804e+37
)
# tdSql.checkData(0,5,None)
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
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: avg basic query ============"
)
tdLog
.
printNoPrefix
(
"==========step4: avg basic query ============"
)
self
.
basic_avg_function
()
tdLog
.
printNoPrefix
(
"==========step5: avg boundary query ============"
)
tdLog
.
printNoPrefix
(
"==========step5: avg boundary query ============"
)
self
.
check_boundary_values
()
tdLog
.
printNoPrefix
(
"==========step6: avg filter query ============"
)
tdLog
.
printNoPrefix
(
"==========step6: avg filter query ============"
)
self
.
avg_func_filter
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录