Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d04e33b5
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看板
提交
d04e33b5
编写于
9月 27, 2021
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6108] <fix> fix the case obout group by and checkDevia
上级
fd86882b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
81 deletion
+46
-81
tests/pytest/functions/queryTestCases.py
tests/pytest/functions/queryTestCases.py
+41
-79
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+5
-2
未找到文件。
tests/pytest/functions/queryTestCases.py
浏览文件 @
d04e33b5
...
...
@@ -1151,21 +1151,39 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
return
tdSql
.
query
(
f
"select
{
col
}
from
{
table_expr
}
{
condition
}
"
)
query_result
=
np
.
array
(
tdSql
.
queryResult
)[
np
.
array
(
tdSql
.
queryResult
)
!=
None
]
pset
=
[
0
,
50
,
100
]
pset
=
[
0
,
40
,
50
,
60
,
100
]
for
pi
in
pset
:
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"'
:
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
)
else
:
tdSql
.
query
(
f
"select
{
col
}
from
{
table_expr
}
{
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
)
def
apercentile_query
(
self
):
...
...
@@ -1255,14 +1273,14 @@ class TDTestCase:
case27
=
{
'alias'
:
', apercentile(c1, 0, "t-digest")'
}
self
.
checkapert
(
**
case27
)
# case28: mix with computing function
# case28
~29
: mix with computing function
case28
=
{
'alias'
:
', spread(c1)'
}
self
.
checkapert
(
**
case28
)
# case29: mix with four operation
case29
=
{
'alias'
:
'+ spread(c1)'
}
self
.
checkapert
(
**
case29
)
# case30~3
5
: with condition
# case30~3
6
: with condition
case30
=
{
'condition'
:
'where ts > now'
}
self
.
checkapert
(
**
case30
)
case31
=
{
'condition'
:
'where c1 between 1 and 200'
}
...
...
@@ -1285,70 +1303,16 @@ class TDTestCase:
self
.
checkapert
(
**
case38
)
# case39: with group by
tdSql
.
query
(
'select min(c1) from stb1 group by tbname'
)
min_result
=
tdSql
.
queryResult
min_len
=
tdSql
.
queryRows
tdSql
.
query
(
'select max(c1) from stb1 group by tbname'
)
max_result
=
tdSql
.
queryResult
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname'
,
p
=
0
))
tdSql
.
checkRows
(
min_len
)
for
i
in
range
(
min_len
):
tdSql
.
checkDeviaRation
(
i
,
0
,
min_result
[
i
][
0
])
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname'
,
p
=
0
))
tdSql
.
checkRows
(
min_len
)
for
i
in
range
(
min_len
):
tdSql
.
checkDeviaRation
(
i
,
0
,
min_result
[
i
][
0
])
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname'
,
p
=
100
))
tdSql
.
checkRows
(
min_len
)
for
i
in
range
(
min_len
):
tdSql
.
checkDeviaRation
(
i
,
0
,
max_result
[
i
][
0
])
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname'
,
p
=
100
))
tdSql
.
checkRows
(
min_len
)
for
i
in
range
(
min_len
):
tdSql
.
checkDeviaRation
(
i
,
0
,
max_result
[
i
][
0
])
case39
=
{
'table_expr'
:
'stb1'
,
'condition'
:
'group by tbname'
}
self
.
checkapert
(
**
case39
)
# case40: with slimit
if
min_len
==
0
:
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
0
))
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
0
))
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
100
))
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
100
))
tdSql
.
checkRows
(
0
)
else
:
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
0
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
min_result
[
0
][
0
])
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
0
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
min_result
[
0
][
0
])
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
100
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
max_result
[
0
][
0
])
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
100
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
max_result
[
0
][
0
])
# case41: with soffset
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1 soffset 1'
,
p
=
0
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
min_result
[
1
][
0
])
case40
=
{
'table_expr'
:
'stb1'
,
'condition'
:
'group by tbname slimit 1'
}
self
.
checkapert
(
**
case40
)
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname slimit 1'
,
p
=
100
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkDeviaRation
(
0
,
0
,
max_result
[
1
][
0
]
)
# case41: with soffset
case41
=
{
'table_expr'
:
'stb1'
,
'condition'
:
'group by tbname slimit 1 soffset 1'
}
self
.
checkapert
(
**
case41
)
# case42: with order by
case42
=
{
'table_expr'
:
'stb1'
,
'condition'
:
'order by ts'
}
...
...
@@ -1356,14 +1320,12 @@ class TDTestCase:
case43
=
{
'table_expr'
:
't1'
,
'condition'
:
'order by ts'
}
self
.
checkapert
(
**
case43
)
# case4
3
: with limit offset
tdSql
.
query
(
self
.
apercentile_query_form
(
algo
=
'"default"'
,
table_expr
=
'stb1'
,
condition
=
'group by tbname limit 1 '
,
p
=
0
))
tdSql
.
checkRows
(
min_len
)
if
min_len
!=
0
:
tdSql
.
checkDeviaRation
(
0
,
0
,
min_result
[
1
][
0
]
)
# case4
4
: with limit offset
case44
=
{
'table_expr'
:
'stb1'
,
'condition'
:
'group by tbname limit 1'
}
self
.
checkapert
(
**
case44
)
case45
=
{
'table_expr'
:
'stb1'
,
'condition'
:
'group by tbname limit 1 offset 1'
}
self
.
checkapert
(
**
case45
)
tdSql
.
query
(
self
.
apercentile_query_form
(
table_expr
=
'stb1'
,
condition
=
'group by tbname limit 1 offset 1'
,
p
=
100
))
tdSql
.
checkRows
(
0
)
pass
def
error_apercentile
(
self
):
...
...
tests/pytest/util/sql.py
浏览文件 @
d04e33b5
...
...
@@ -253,8 +253,11 @@ class TDSql:
devia
=
abs
((
data
-
self
.
queryResult
[
row
][
col
])
/
data
)
if
devia
<=
deviation
:
tdLog
.
info
(
f
"sql:
{
self
.
sql
}
, result data:
{
self
.
queryResult
[
row
][
col
]
}
, expect data:
{
data
}
, "
f
"actual deviation:
{
devia
}
<= expect deviation:
{
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
]
}
"
)
pass
def
getData
(
self
,
row
,
col
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录