Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8175b36d
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看板
提交
8175b36d
编写于
2月 22, 2023
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test cases
上级
39d38c15
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
9 deletion
+37
-9
tests/system-test/2-query/percentile.py
tests/system-test/2-query/percentile.py
+37
-9
未找到文件。
tests/system-test/2-query/percentile.py
浏览文件 @
8175b36d
...
...
@@ -50,7 +50,7 @@ class TDTestCase:
'col12'
:
f
'binary(
{
self
.
binary_length
}
)'
,
'col13'
:
f
'nchar(
{
self
.
nchar_length
}
)'
}
self
.
tag_dict
=
{
'ts_tag'
:
'timestamp'
,
't1'
:
'tinyint'
,
...
...
@@ -85,19 +85,19 @@ class TDTestCase:
self
.
tag_values
=
[
f
'
{
self
.
tag_ts
}
,
{
self
.
tag_tinyint
}
,
{
self
.
tag_smallint
}
,
{
self
.
tag_int
}
,
{
self
.
tag_bigint
}
,
\
{
self
.
tag_utint
}
,
{
self
.
tag_usint
}
,
{
self
.
tag_uint
}
,
{
self
.
tag_ubint
}
,
{
self
.
tag_float
}
,
{
self
.
tag_double
}
,
{
self
.
tag_bool
}
,"
{
self
.
binary_str
}
","
{
self
.
nchar_str
}
"'
]
self
.
param
=
[
1
,
50
,
100
]
def
insert_data
(
self
,
column_dict
,
tbname
,
row_num
):
intData
=
[]
intData
=
[]
floatData
=
[]
insert_sql
=
self
.
setsql
.
set_insertsql
(
column_dict
,
tbname
,
self
.
binary_str
,
self
.
nchar_str
)
for
i
in
range
(
row_num
):
insert_list
=
[]
self
.
setsql
.
insert_values
(
column_dict
,
i
,
insert_sql
,
insert_list
,
self
.
ts
)
intData
.
append
(
i
)
intData
.
append
(
i
)
floatData
.
append
(
i
+
0.1
)
return
intData
,
floatData
def
check_tags
(
self
,
tags
,
param
,
num
,
value
):
...
...
@@ -117,6 +117,20 @@ class TDTestCase:
else
:
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
param
))
tdSql
.
query
(
f
'select percentile(col1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) from
{
self
.
ntbname
}
'
)
tdSql
.
checkData
(
0
,
0
,
'[0.900000, 1.800000, 2.700000, 3.600000, 4.500000, 5.400000, 6.300000, 7.200000, 8.100000, 9.000000]'
)
tdSql
.
query
(
f
'select percentile(col1, 9.9, 19.9, 29.9, 39.9, 49.9, 59.9, 69.9, 79.9, 89.9, 99.9) from
{
self
.
ntbname
}
'
)
tdSql
.
checkData
(
0
,
0
,
'[0.891000, 1.791000, 2.691000, 3.591000, 4.491000, 5.391000, 6.291000, 7.191000, 8.091000, 8.991000]'
)
tdSql
.
error
(
f
'select percentile(col1) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select percentile(col1, -1) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select percentile(col1, 101) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select percentile(col1, col2) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select percentile(1, col1) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select percentile(col1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 101) from
{
self
.
ntbname
}
'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
function_check_ctb
(
self
):
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
...
...
@@ -135,7 +149,7 @@ class TDTestCase:
else
:
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
param
))
for
k
,
v
in
self
.
tag_dict
.
items
():
for
param
in
self
.
param
:
if
v
.
lower
()
in
[
'timestamp'
,
'bool'
]
or
'binary'
in
v
.
lower
()
or
'nchar'
in
v
.
lower
():
...
...
@@ -145,11 +159,25 @@ class TDTestCase:
data_num
=
tdSql
.
queryResult
[
0
][
0
]
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkData
(
0
,
0
,
data_num
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
tdSql
.
query
(
f
'select percentile(col1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) from
{
self
.
stbname
}
_0'
)
tdSql
.
checkData
(
0
,
0
,
'[0.900000, 1.800000, 2.700000, 3.600000, 4.500000, 5.400000, 6.300000, 7.200000, 8.100000, 9.000000]'
)
tdSql
.
query
(
f
'select percentile(col1, 9.9, 19.9, 29.9, 39.9, 49.9, 59.9, 69.9, 79.9, 89.9, 99.9) from
{
self
.
stbname
}
_0'
)
tdSql
.
checkData
(
0
,
0
,
'[0.891000, 1.791000, 2.691000, 3.591000, 4.491000, 5.391000, 6.291000, 7.191000, 8.091000, 8.991000]'
)
tdSql
.
error
(
f
'select percentile(col1) from
{
self
.
stbname
}
_0'
)
tdSql
.
error
(
f
'select percentile(col1, -1) from
{
self
.
stbname
}
_0'
)
tdSql
.
error
(
f
'select percentile(col1, 101) from
{
self
.
stbname
}
_0'
)
tdSql
.
error
(
f
'select percentile(col1, col2) from
{
self
.
stbname
}
_0'
)
tdSql
.
error
(
f
'select percentile(1, col1) from
{
self
.
stbname
}
_0'
)
tdSql
.
error
(
f
'select percentile(col1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 101) from
{
self
.
stbname
}
_0'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
self
.
function_check_ntb
()
self
.
function_check_ctb
()
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录