Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ee1f0989
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
ee1f0989
编写于
9月 29, 2021
作者:
C
cpwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6108] <fix> fix the case
上级
7222bb45
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
41 addition
and
22 deletion
+41
-22
tests/pytest/functions/queryTestCases.py
tests/pytest/functions/queryTestCases.py
+38
-20
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+3
-2
未找到文件。
tests/pytest/functions/queryTestCases.py
浏览文件 @
ee1f0989
...
@@ -1137,10 +1137,7 @@ class TDTestCase:
...
@@ -1137,10 +1137,7 @@ class TDTestCase:
:return: apercentile query statement,default: select apercentile(c1, 0, 1) from t1
:return: apercentile query statement,default: select apercentile(c1, 0, 1) from t1
'''
'''
if
alias
:
return
f
"select apercentile(
{
col
}
,
{
p
}{
com
}
{
algo
}
)
{
alias
}
from
{
table_expr
}
{
condition
}
"
return
f
"select apercentile(
{
col
}
,
{
p
}{
com
}
{
algo
}
)
{
alias
}
from
{
table_expr
}
{
condition
}
"
else
:
return
f
"select apercentile(
{
col
}
,
{
p
}{
com
}
{
algo
}
) from
{
table_expr
}
{
condition
}
"
def
checkapert
(
self
,
col
=
"c1"
,
p
=
0
,
com
=
','
,
algo
=
'"t-digest"'
,
alias
=
""
,
table_expr
=
"t1"
,
condition
=
""
):
def
checkapert
(
self
,
col
=
"c1"
,
p
=
0
,
com
=
','
,
algo
=
'"t-digest"'
,
alias
=
""
,
table_expr
=
"t1"
,
condition
=
""
):
...
@@ -1165,28 +1162,54 @@ class TDTestCase:
...
@@ -1165,28 +1162,54 @@ class TDTestCase:
for
pi
in
pset
:
for
pi
in
pset
:
if
"group"
in
condition
:
if
"group"
in
condition
:
tdSql
.
query
(
self
.
apercentile_query_form
(
tdSql
.
query
(
f
"select last_row(
{
col
}
) from
{
table_expr
}
{
condition
}
"
)
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"default"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
query_result
=
tdSql
.
queryResult
query_result
=
tdSql
.
queryResult
query_rows
=
tdSql
.
queryRows
query_rows
=
tdSql
.
queryRows
for
i
in
range
(
query_rows
):
pre_condition
=
condition
.
replace
(
"slimit"
,
'limit'
).
replace
(
"group by tbname"
,
""
).
split
(
"soffset"
)[
0
]
tbname
=
query_result
[
i
][
-
1
]
tdSql
.
query
(
f
"select percentile(
{
col
}
,
{
pi
}
)
{
alias
}
from
{
tbname
}
{
pre_condition
}
"
)
print
(
tdSql
.
sql
)
pre_data
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
self
.
apercentile_query_form
(
tdSql
.
query
(
self
.
apercentile_query_form
(
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"t-digest"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
col
=
col
,
p
=
pi
,
com
=
com
,
algo
=
'"t-digest"'
,
alias
=
alias
,
table_expr
=
table_expr
,
condition
=
condition
))
))
for
i
in
range
(
query_rows
):
if
abs
(
tdSql
.
getData
(
i
,
0
))
>=
(
spread_num
*
0.02
):
if
abs
(
tdSql
.
getData
(
i
,
0
))
>=
(
spread_num
*
0.02
):
tdSql
.
checkDeviaRation
(
i
,
0
,
query_result
[
i
][
0
]
,
0.1
)
tdSql
.
checkDeviaRation
(
i
,
0
,
pre_data
,
0.1
)
else
:
else
:
devia
=
abs
((
tdSql
.
getData
(
i
,
0
)
-
query_result
[
i
][
0
]
)
/
(
spread_num
*
0.02
))
devia
=
abs
((
tdSql
.
getData
(
i
,
0
)
-
pre_data
)
/
(
spread_num
*
0.02
))
if
devia
<
0.5
:
if
devia
<
0.5
:
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, result data:
{
tdSql
.
getData
(
i
,
0
)
}
, expect data:
{
tdSql
.
queryResult
[
i
][
0
]
}
, "
tdLog
.
info
(
f
"sql:
{
tdSql
.
sql
}
, result data:
{
tdSql
.
getData
(
i
,
0
)
}
, expect data:
{
pre_data
}
, "
f
"actual deviation:
{
devia
}
<= expect deviation: 0.01"
)
f
"actual deviation:
{
devia
}
<= expect deviation: 0.01"
)
else
:
else
:
tdLog
.
exit
(
tdLog
.
exit
(
f
"[
{
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
]).
lineno
}
],check failed:sql:
{
tdSql
.
sql
}
, "
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
"result data:
{
tdSql
.
getData
(
i
,
0
)
}
, expect data:
{
pre_data
}
, "
f
"actual deviation:
{
devia
}
> expect deviation: 0.01"
)
f
"actual deviation:
{
devia
}
> expect deviation: 0.01"
)
# 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
# ))
# 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
# ))
# for i in range(query_rows):
# 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
:
else
:
if
','
in
alias
or
not
alias
:
if
','
in
alias
or
not
alias
:
tdSql
.
query
(
f
"select
{
col
}
from
{
table_expr
}
{
condition
}
"
)
tdSql
.
query
(
f
"select
{
col
}
from
{
table_expr
}
{
condition
}
"
)
...
@@ -1215,11 +1238,6 @@ class TDTestCase:
...
@@ -1215,11 +1238,6 @@ class TDTestCase:
f
"result data:
{
tdSql
.
getData
(
0
,
0
)
}
, expect data:
{
np
.
percentile
(
query_result
,
pi
)
}
, "
f
"result data:
{
tdSql
.
getData
(
0
,
0
)
}
, expect data:
{
np
.
percentile
(
query_result
,
pi
)
}
, "
f
"actual deviation:
{
devia
}
> expect deviation: 0.01"
)
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
):
def
apercentile_query
(
self
):
...
@@ -1504,7 +1522,7 @@ class TDTestCase:
...
@@ -1504,7 +1522,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"######## insert data test:"
)
tdLog
.
printNoPrefix
(
"######## insert data test:"
)
nowtime
=
int
(
round
(
time
.
time
()
*
1000
))
nowtime
=
int
(
round
(
time
.
time
()
*
1000
))
per_table_rows
=
100
per_table_rows
=
100
0
self
.
apercentile_data
(
tbnum
,
per_table_rows
,
nowtime
)
self
.
apercentile_data
(
tbnum
,
per_table_rows
,
nowtime
)
self
.
apercentile_query
()
self
.
apercentile_query
()
self
.
error_apercentile
()
self
.
error_apercentile
()
...
...
tests/pytest/util/sql.py
浏览文件 @
ee1f0989
...
@@ -256,10 +256,11 @@ class TDSql:
...
@@ -256,10 +256,11 @@ class TDSql:
else
:
else
:
devia
=
abs
((
data
-
self
.
queryResult
[
row
][
col
])
/
data
)
devia
=
abs
((
data
-
self
.
queryResult
[
row
][
col
])
/
data
)
if
devia
<=
deviation
:
if
devia
<=
deviation
:
tdLog
.
info
(
f
"sql:
{
args
[
2
]
}
, result data:
{
args
[
7
]
}
, expect data:
{
args
[
3
]
}
, "
tdLog
.
info
(
f
"sql:
{
args
[
2
]
}
, r
ow:
{
row
}
, col:
{
col
}
, r
esult data:
{
args
[
7
]
}
, expect data:
{
args
[
3
]
}
, "
f
"actual deviation:
{
devia
}
<= expect deviation:
{
args
[
5
]
}
"
)
f
"actual deviation:
{
devia
}
<= expect deviation:
{
args
[
5
]
}
"
)
else
:
else
:
tdLog
.
exit
(
f
"
{
args
[
0
]
}
(
{
args
[
1
]
}
) failed: sql:
{
args
[
2
]
}
, result data:
{
args
[
7
]
}
, expect data:
{
args
[
3
]
}
,"
tdLog
.
exit
(
f
"
{
args
[
0
]
}
(
{
args
[
1
]
}
) failed: sql:
{
args
[
2
]
}
, row:
{
row
}
, col:
{
col
}
, "
f
"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
pass
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录