Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
377231fd
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看板
未验证
提交
377231fd
编写于
8月 23, 2021
作者:
H
Hui Li
提交者:
GitHub
8月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7491 from taosdata/test/td-6223
[TD-6223]concurrent query support nested query
上级
f5a8cb63
5053132c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
10 deletion
+66
-10
tests/pytest/concurrent_inquiry.py
tests/pytest/concurrent_inquiry.py
+66
-10
未找到文件。
tests/pytest/concurrent_inquiry.py
浏览文件 @
377231fd
...
...
@@ -175,12 +175,62 @@ class ConcurrentInquiry:
def
con_group
(
self
,
tlist
,
col_list
,
tag_list
):
rand_tag
=
random
.
randint
(
0
,
5
)
rand_col
=
random
.
randint
(
0
,
1
)
return
'group by '
+
','
.
join
(
random
.
sample
(
col_list
,
rand_col
)
+
random
.
sample
(
tag_list
,
rand_tag
))
if
len
(
tag_list
):
return
'group by '
+
','
.
join
(
random
.
sample
(
col_list
,
rand_col
)
+
random
.
sample
(
tag_list
,
rand_tag
))
else
:
return
'group by '
+
','
.
join
(
random
.
sample
(
col_list
,
rand_col
))
def
con_order
(
self
,
tlist
,
col_list
,
tag_list
):
return
'order by '
+
random
.
choice
(
tlist
)
def
gen_query_sql
(
self
):
#生成查询语句
def
gen_subquery_sql
(
self
):
subsql
,
col_num
=
self
.
gen_query_sql
(
1
)
if
col_num
==
0
:
return
0
col_list
=
[]
tag_list
=
[]
for
i
in
range
(
col_num
):
col_list
.
append
(
"taosd%d"
%
i
)
tlist
=
col_list
+
[
'abc'
]
#增加不存在的域'abc',是否会引起新bug
con_rand
=
random
.
randint
(
0
,
len
(
condition_list
))
func_rand
=
random
.
randint
(
0
,
len
(
func_list
))
col_rand
=
random
.
randint
(
0
,
len
(
col_list
))
t_rand
=
random
.
randint
(
0
,
len
(
tlist
))
sql
=
'select '
#select
random
.
shuffle
(
col_list
)
random
.
shuffle
(
func_list
)
sel_col_list
=
[]
col_rand
=
random
.
randint
(
0
,
len
(
col_list
))
loop
=
0
for
i
,
j
in
zip
(
col_list
[
0
:
col_rand
],
func_list
):
#决定每个被查询col的函数
alias
=
' as '
+
'sub%d '
%
loop
loop
+=
1
pick_func
=
''
if
j
==
'leastsquares'
:
pick_func
=
j
+
'('
+
i
+
',1,1)'
elif
j
==
'top'
or
j
==
'bottom'
or
j
==
'percentile'
or
j
==
'apercentile'
:
pick_func
=
j
+
'('
+
i
+
',1)'
else
:
pick_func
=
j
+
'('
+
i
+
')'
if
bool
(
random
.
getrandbits
(
1
))
:
pick_func
+=
alias
sel_col_list
.
append
(
pick_func
)
if
col_rand
==
0
:
sql
=
sql
+
'*'
else
:
sql
=
sql
+
','
.
join
(
sel_col_list
)
#select col & func
sql
=
sql
+
' from ('
+
subsql
+
') '
con_func
=
[
self
.
con_where
,
self
.
con_interval
,
self
.
con_limit
,
self
.
con_group
,
self
.
con_order
,
self
.
con_fill
]
sel_con
=
random
.
sample
(
con_func
,
random
.
randint
(
0
,
len
(
con_func
)))
sel_con_list
=
[]
for
i
in
sel_con
:
sel_con_list
.
append
(
i
(
tlist
,
col_list
,
tag_list
))
#获取对应的条件函数
sql
+=
' '
.
join
(
sel_con_list
)
# condition
#print(sql)
return
sql
def
gen_query_sql
(
self
,
subquery
=
0
):
#生成查询语句
tbi
=
random
.
randint
(
0
,
len
(
self
.
subtb_list
)
+
len
(
self
.
stb_list
))
#随机决定查询哪张表
tbname
=
''
col_list
=
[]
...
...
@@ -218,10 +268,10 @@ class ConcurrentInquiry:
pick_func
=
j
+
'('
+
i
+
',1)'
else
:
pick_func
=
j
+
'('
+
i
+
')'
if
bool
(
random
.
getrandbits
(
1
)):
if
bool
(
random
.
getrandbits
(
1
))
|
subquery
:
pick_func
+=
alias
sel_col_list
.
append
(
pick_func
)
if
col_rand
==
0
:
if
col_rand
==
0
&
subquery
:
sql
=
sql
+
'*'
else
:
sql
=
sql
+
','
.
join
(
sel_col_list
)
#select col & func
...
...
@@ -238,7 +288,7 @@ class ConcurrentInquiry:
sel_con_list
.
append
(
i
(
tlist
,
col_list
,
tag_list
))
#获取对应的条件函数
sql
+=
' '
.
join
(
sel_con_list
)
# condition
#print(sql)
return
sql
return
(
sql
,
loop
)
def
gen_query_join
(
self
):
#生成join查询语句
tbname
=
[]
...
...
@@ -429,9 +479,12 @@ class ConcurrentInquiry:
try
:
if
self
.
random_pick
():
sql
=
self
.
gen_query_sql
()
if
self
.
random_pick
():
sql
,
temp
=
self
.
gen_query_sql
()
else
:
sql
=
self
.
gen_subquery_sql
()
else
:
sql
=
self
.
gen_query_join
()
sql
=
self
.
gen_query_join
()
print
(
"sql is "
,
sql
)
fo
.
write
(
sql
+
'
\n
'
)
start
=
time
.
time
()
...
...
@@ -496,9 +549,12 @@ class ConcurrentInquiry:
while
loop
:
try
:
if
self
.
random_pick
():
sql
=
self
.
gen_query_sql
()
if
self
.
random_pick
():
sql
,
temp
=
self
.
gen_query_sql
()
else
:
sql
=
self
.
gen_subquery_sql
()
else
:
sql
=
self
.
gen_query_join
()
sql
=
self
.
gen_query_join
()
print
(
"sql is "
,
sql
)
fo
.
write
(
sql
+
'
\n
'
)
start
=
time
.
time
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录