Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9f13a3c7
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看板
提交
9f13a3c7
编写于
9月 28, 2021
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6217] <fix> fix the case
上级
b762a699
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
71 addition
and
30 deletion
+71
-30
tests/pytest/functions/queryTestCases.py
tests/pytest/functions/queryTestCases.py
+66
-28
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+5
-2
未找到文件。
tests/pytest/functions/queryTestCases.py
浏览文件 @
9f13a3c7
...
...
@@ -16,6 +16,7 @@ import subprocess
import
random
import
math
import
numpy
as
np
import
inspect
from
util.log
import
*
from
util.cases
import
*
...
...
@@ -1151,39 +1152,74 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
return
pset
=
[
0
,
40
,
50
,
60
,
100
]
pset
=
[
0
,
40
,
60
,
100
]
if
p
not
in
pset
:
pset
.
append
(
p
)
if
"stb"
in
table_expr
:
tdSql
.
query
(
f
"select spread(
{
col
}
) from stb1"
)
else
:
tdSql
.
query
(
f
"select avg(c1) from (select spread(
{
col
.
split
(
'.'
)[
-
1
]
}
) c1 from stb1 group by tbname)"
)
spread_num
=
tdSql
.
getData
(
0
,
0
)
for
pi
in
pset
:
if
"group"
in
condition
:
tdSql
.
query
(
self
.
apercentile_query_form
(
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"default"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
print
(
tdSql
.
sql
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryRows
)
query_result
=
tdSql
.
queryResult
query_rows
=
tdSql
.
queryRows
tdSql
.
query
(
self
.
apercentile_query_form
(
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"t-digest"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
print
(
tdSql
.
sql
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryRows
)
for
i
in
range
(
query_rows
):
tdSql
.
checkDeviaRation
(
i
,
0
,
query_result
[
i
][
0
],
0.001
)
if
abs
(
tdSql
.
getData
(
i
,
0
))
>=
(
spread_num
*
0.02
):
tdSql
.
checkDeviaRation
(
i
,
0
,
query_result
[
i
][
0
],
0.1
)
else
:
devia
=
abs
((
tdSql
.
getData
(
i
,
0
)
-
query_result
[
i
][
0
])
/
(
spread_num
*
0.02
))
if
devia
<
0.5
:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, result data:
{
tdSql
.
getData
(
i
,
0
)
}
, expect data:
{
tdSql
.
queryResult
[
i
][
0
]
}
, "
f
"actual deviation:
{
devia
}
<= expect deviation: 0.01"
)
else
:
tdLog
.
exit
(
f
"[
{
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
]).
lineno
}
],check failed:sql:
{
tdSql
.
sql
}
, "
f
"result data:
{
tdSql
.
getData
(
i
,
0
)
}
, expect data:
{
tdSql
.
queryResult
[
i
][
0
]
}
, "
f
"actual deviation:
{
devia
}
> expect deviation: 0.01"
)
else
:
tdSql
.
query
(
f
"select
{
col
}
from
{
table_expr
}
{
condition
}
"
)
if
','
in
alias
or
not
alias
:
tdSql
.
query
(
f
"select
{
col
}
from
{
table_expr
}
{
condition
}
"
)
elif
"stb"
not
in
table_expr
:
tdSql
.
query
(
f
"select percentile(
{
col
}
,
{
pi
}
)
{
alias
}
from
{
table_expr
}
{
condition
}
"
)
else
:
tdSql
.
query
(
self
.
apercentile_query_form
(
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"default"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
query_result
=
np
.
array
(
tdSql
.
queryResult
)[
np
.
array
(
tdSql
.
queryResult
)
!=
None
]
tdSql
.
query
(
self
.
apercentile_query_form
(
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
algo
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
pi
),
0.001
)
if
algo
==
'"t-digest"'
:
tdSql
.
query
(
self
.
apercentile_query_form
(
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"default"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
pi
),
0.001
)
if
abs
(
tdSql
.
getData
(
0
,
0
))
>=
(
spread_num
*
0.02
):
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
pi
),
0.1
)
else
:
devia
=
abs
((
tdSql
.
getData
(
0
,
0
)
-
np
.
percentile
(
query_result
,
pi
))
/
(
spread_num
*
0.02
))
if
devia
<
0.5
:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, result data:
{
tdSql
.
getData
(
0
,
0
)
}
, expect data:
{
np
.
percentile
(
query_result
,
pi
)
}
, "
f
"actual deviation:
{
devia
}
<= expect deviation: 0.01"
)
else
:
tdLog
.
exit
(
f
"[
{
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
]).
lineno
}
],check failed:sql:
{
tdSql
.
sql
}
, "
f
"result data:
{
tdSql
.
getData
(
0
,
0
)
}
, expect data:
{
np
.
percentile
(
query_result
,
pi
)
}
, "
f
"actual deviation:
{
devia
}
> expect deviation: 0.01"
)
# if algo == '"t-digest"':
# tdSql.query(self.apercentile_query_form(
# col=col, p=pi, com=com, algo='"default"', alias=alias, table_expr=table_expr, condition=condition
# ))
# tdSql.checkDeviaRation(0, 0, np.percentile(query_result, pi), 0.1)
def
apercentile_query
(
self
):
...
...
@@ -1225,11 +1261,11 @@ class TDTestCase:
else
:
query_result
=
np
.
array
(
tdSql
.
queryResult
)[
np
.
array
(
tdSql
.
queryResult
)
!=
None
]
tdSql
.
query
(
"select * from (select apercentile(c1, 0) c1 from stb1)"
)
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
0
),
0.
00
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
0
),
0.1
)
tdSql
.
query
(
"select * from (select apercentile(c1,100) c1 from stb1)"
)
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
100
),
0.
00
1
)
tdSql
.
query
(
"select * from (select apercentile(c1,
5
0) c1 from stb1)"
)
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
50
),
0.00
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
100
),
0.1
)
tdSql
.
query
(
"select * from (select apercentile(c1,
4
0) c1 from stb1)"
)
tdSql
.
checkDeviaRation
(
0
,
0
,
np
.
percentile
(
query_result
,
40
),
0.
1
)
# case11: no algorithm = algo:0
case11
=
{
'com'
:
''
,
'algo'
:
''
}
...
...
@@ -1419,9 +1455,9 @@ class TDTestCase:
tdSql
.
error
(
self
.
apercentile_query_form
(
alias
=
', diff(c1)'
))
# mix with diff function
tdSql
.
error
(
self
.
apercentile_query_form
(
alias
=
'+ c1)'
))
# mix with four operation
def
apercentile_data
(
self
,
basetime
):
for
i
in
range
(
10
):
for
j
in
range
(
10
):
def
apercentile_data
(
self
,
tbnum
,
data_row
,
basetime
):
for
i
in
range
(
tbnum
):
for
j
in
range
(
data_row
):
tdSql
.
execute
(
f
"insert into t
{
i
}
values ("
f
"
{
basetime
+
j
*
10
}
,
{
random
.
randint
(
-
200
,
-
1
)
}
,
{
random
.
uniform
(
200
,
-
1
)
}
,
{
basetime
+
random
.
randint
(
-
200
,
-
1
)
}
, "
...
...
@@ -1457,7 +1493,8 @@ class TDTestCase:
tdSql
.
execute
(
"create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)"
)
for
i
in
range
(
100
):
tbnum
=
10
for
i
in
range
(
tbnum
):
tdSql
.
execute
(
f
"create table t
{
i
}
using stb1 tags(
{
i
}
)"
)
tdSql
.
execute
(
f
"create table tt
{
i
}
using stb2 tags(
{
i
}
)"
)
...
...
@@ -1467,7 +1504,8 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"######## insert data test:"
)
nowtime
=
int
(
round
(
time
.
time
()
*
1000
))
self
.
apercentile_data
(
nowtime
)
per_table_rows
=
100
self
.
apercentile_data
(
tbnum
,
per_table_rows
,
nowtime
)
self
.
apercentile_query
()
self
.
error_apercentile
()
...
...
@@ -1498,11 +1536,11 @@ class TDTestCase:
# self.td6068()
# develop branch
self
.
td4097
()
self
.
td4889
()
#
self.td4097()
#
self.td4889()
# self.td5168()
self
.
td5798
()
self
.
td5433
()
#
self.td5798()
#
self.td5433()
self
.
td6108
()
def
stop
(
self
):
...
...
tests/pytest/util/sql.py
浏览文件 @
9f13a3c7
...
...
@@ -251,13 +251,16 @@ class TDSql:
tdLog
.
exit
(
f
"
{
args
[
0
]
}
(
{
args
[
1
]
}
) failed: sql:
{
args
[
2
]
}
, result:
{
args
[
7
]
}
, "
f
"expect type: int or float, actual type:
{
args
[
8
]
}
"
)
devia
=
abs
((
data
-
self
.
queryResult
[
row
][
col
])
/
data
)
if
data
==
0
:
devia
=
abs
(
self
.
queryResult
[
row
][
col
])
else
:
devia
=
abs
((
data
-
self
.
queryResult
[
row
][
col
])
/
data
)
if
devia
<=
deviation
:
tdLog
.
info
(
f
"sql:
{
args
[
2
]
}
, result data:
{
args
[
7
]
}
, expect data:
{
args
[
3
]
}
, "
f
"actual deviation:
{
devia
}
<= expect deviation:
{
args
[
5
]
}
"
)
else
:
tdLog
.
exit
(
f
"
{
args
[
0
]
}
(
{
args
[
1
]
}
) failed: sql:
{
args
[
2
]
}
, result data:
{
args
[
7
]
}
, expect data:
{
args
[
3
]
}
,"
f
"actual deviation:
{
devia
}
<=
expect deviation:
{
args
[
5
]
}
"
)
f
"actual deviation:
{
devia
}
>
expect deviation:
{
args
[
5
]
}
"
)
pass
def
getData
(
self
,
row
,
col
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录