Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
72ad2fe8
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
72ad2fe8
编写于
5月 30, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update apercentile.py
上级
2aad54c0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
21 deletion
+29
-21
tests/system-test/2-query/apercentile.py
tests/system-test/2-query/apercentile.py
+29
-21
未找到文件。
tests/system-test/2-query/apercentile.py
浏览文件 @
72ad2fe8
...
...
@@ -21,23 +21,21 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
check_apercentile
(
self
,
data
,
expect_data
,
param
,
percent
):
def
check_apercentile
(
self
,
data
,
expect_data
,
param
,
percent
,
column
):
if
param
==
"default"
:
if
abs
((
expect_data
-
data
)
<=
expect_data
*
0.2
):
tdLog
.
info
(
f
"apercentile function values check success with
param=
{
param
}
,percent=
{
percent
}
"
)
tdLog
.
info
(
f
"apercentile function values check success with
col
{
column
}
, param =
{
param
}
,percent =
{
percent
}
"
)
else
:
tdLog
.
notice
(
f
"apercentile function value has not as expected with
param=
{
param
}
,percent=
{
percent
}
"
)
tdLog
.
notice
(
f
"apercentile function value has not as expected with
col
{
column
}
, param =
{
param
}
,percent =
{
percent
}
"
)
sys
.
exit
(
1
)
elif
param
==
"t-digest"
:
if
abs
((
expect_data
-
data
)
<=
expect_data
*
0.2
):
tdLog
.
info
(
f
"apercentile function values check success with
param=
{
param
}
,percent=
{
percent
}
"
)
tdLog
.
info
(
f
"apercentile function values check success with
col
{
column
}
, param =
{
param
}
,percent =
{
percent
}
"
)
else
:
tdLog
.
notice
(
f
"apercentile function value has not as expected with
param=
{
param
}
,percent=
{
percent
}
"
)
tdLog
.
notice
(
f
"apercentile function value has not as expected with
col
{
column
}
, param =
{
param
}
,percent =
{
percent
}
"
)
sys
.
exit
(
1
)
def
run
(
self
):
...
...
@@ -45,7 +43,8 @@ class TDTestCase:
intData
=
[]
floatData
=
[]
percent_list
=
[
0
,
50
,
100
]
param_list
=
[
'default'
,
't-digest'
]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
for
i
in
range
(
self
.
rowNum
):
...
...
@@ -62,8 +61,7 @@ class TDTestCase:
tdSql
.
error
(
"select apercentile(col9 ,20) from test"
)
column_list
=
[
1
,
2
,
3
,
4
,
5
,
6
,
11
,
12
,
13
,
14
]
percent_list
=
[
0
,
50
,
100
]
param_list
=
[
'default'
,
't-digest'
]
for
i
in
column_list
:
for
j
in
percent_list
:
for
k
in
param_list
:
...
...
@@ -71,7 +69,11 @@ class TDTestCase:
data
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
f
"select percentile(col
{
i
}
,
{
j
}
) from test"
)
expect_data
=
tdSql
.
getData
(
0
,
0
)
self
.
check_apercentile
(
data
,
expect_data
,
k
)
self
.
check_apercentile
(
data
,
expect_data
,
k
,
j
,
i
)
error_param_list
=
[
-
1
,
101
,
'"a"'
]
for
i
in
error_param_list
:
tdSql
.
error
(
f
'select apercentile(col1,
{
i
}
) from test'
)
tdSql
.
execute
(
"create table meters (ts timestamp, voltage int) tags(loc nchar(20))"
)
tdSql
.
execute
(
"create table t0 using meters tags('beijing')"
)
...
...
@@ -80,17 +82,23 @@ class TDTestCase:
tdSql
.
execute
(
"insert into t0 values(%d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
))
tdSql
.
execute
(
"insert into t1 values(%d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
))
tdSql
.
query
(
"select apercentile(voltage, 20) from meters"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
column_list
=
[
'voltage'
]
for
i
in
column_list
:
for
j
in
percent_list
:
for
k
in
param_list
:
tdSql
.
query
(
f
"select apercentile(
{
i
}
,
{
j
}
,'
{
k
}
') from t0"
)
data
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
f
"select percentile(
{
i
}
,
{
j
}
) from t0"
)
expect_data
=
tdSql
.
getData
(
0
,
0
)
self
.
check_apercentile
(
data
,
expect_data
,
k
,
j
,
i
)
tdSql
.
query
(
f
"select apercentile(
{
i
}
,
{
j
}
,'
{
k
}
') from meters"
)
tdSql
.
checkRows
(
1
)
table_list
=
[
"meters"
,
"t0"
]
for
i
in
error_param_list
:
for
j
in
table_list
:
for
k
in
column_list
:
tdSql
.
error
(
f
'select apercentile(
{
k
}
,
{
i
}
) from
{
j
}
'
)
tdSql
.
execute
(
"create table st(ts timestamp, k int)"
)
tdSql
.
execute
(
"insert into st values(now, -100)(now+1a,-99)"
)
tdSql
.
query
(
"select apercentile(k, 20) from st"
)
tdSql
.
checkData
(
0
,
0
,
-
100.00
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录