Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
40cbe4c2
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40cbe4c2
编写于
2月 24, 2019
作者:
A
alesapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add hierarchical tests
上级
da33310f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
6 deletion
+51
-6
dbms/tests/integration/test_external_dictionaries/dictionary.py
...ests/integration/test_external_dictionaries/dictionary.py
+31
-0
dbms/tests/integration/test_external_dictionaries/test.py
dbms/tests/integration/test_external_dictionaries/test.py
+20
-6
未找到文件。
dbms/tests/integration/test_external_dictionaries/dictionary.py
浏览文件 @
40cbe4c2
...
...
@@ -251,6 +251,31 @@ class DictionaryStructure(object):
return
[
self
.
_get_dict_get_common_expression
(
dict_name
,
field
,
row
,
or_default
=
False
,
with_type
=
False
,
has
=
True
)]
return
[]
def
get_hierarchical_expressions
(
self
,
dict_name
,
row
):
if
self
.
layout
.
is_simple
:
key_expr
=
'toUInt64({})'
.
format
(
row
.
data
[
self
.
keys
[
0
].
name
])
return
[
"dictGetHierarchy('{dict_name}', {key})"
.
format
(
dict_name
=
dict_name
,
key
=
key_expr
,
),
]
return
[]
def
get_is_in_expressions
(
self
,
dict_name
,
row
,
parent_row
):
if
self
.
layout
.
is_simple
:
child_key_expr
=
'toUInt64({})'
.
format
(
row
.
data
[
self
.
keys
[
0
].
name
])
parent_key_expr
=
'toUInt64({})'
.
format
(
parent_row
.
data
[
self
.
keys
[
0
].
name
])
return
[
"dictIsIn('{dict_name}', {child_key}, {parent_key})"
.
format
(
dict_name
=
dict_name
,
child_key
=
child_key_expr
,
parent_key
=
parent_key_expr
,)
]
return
[]
class
Dictionary
(
object
):
def
__init__
(
self
,
name
,
structure
,
source
,
config_path
,
table_name
):
...
...
@@ -300,5 +325,11 @@ class Dictionary(object):
def
get_select_has_queries
(
self
,
field
,
row
):
return
[
'select {}'
.
format
(
expr
)
for
expr
in
self
.
structure
.
get_has_expressions
(
self
.
name
,
field
,
row
)]
def
get_hierarchical_queries
(
self
,
row
):
return
[
'select {}'
.
format
(
expr
)
for
expr
in
self
.
structure
.
get_hierarchical_expressions
(
self
.
name
,
row
)]
def
get_is_in_queries
(
self
,
row
,
parent_row
):
return
[
'select {}'
.
format
(
expr
)
for
expr
in
self
.
structure
.
get_is_in_expressions
(
self
.
name
,
row
,
parent_row
)]
def
is_complex
(
self
):
return
self
.
structure
.
layout
.
is_complex
dbms/tests/integration/test_external_dictionaries/test.py
浏览文件 @
40cbe4c2
...
...
@@ -26,6 +26,7 @@ FIELDS = {
Field
(
"String_"
,
'String'
,
default_value_for_get
=
'hi'
),
Field
(
"Float32_"
,
'Float32'
,
default_value_for_get
=
555.11
),
Field
(
"Float64_"
,
'Float64'
,
default_value_for_get
=
777.11
),
Field
(
"ParentKeyField"
,
"UInt64"
,
default_value_for_get
=
444
,
hierarchical
=
True
)
],
"complex"
:
[
Field
(
"KeyField1"
,
'UInt64'
,
is_key
=
True
,
default_value_for_get
=
9999999
),
...
...
@@ -78,7 +79,7 @@ LAYOUTS = [
]
SOURCES
=
[
# some
kind of
troubles with that dictionary
# some troubles with that dictionary
#SourceMongo("MongoDB", "localhost", "27018", "mongo1", "27017", "root", "clickhouse"),
SourceMySQL
(
"MySQL"
,
"localhost"
,
"3308"
,
"mysql1"
,
"3306"
,
"root"
,
"clickhouse"
),
SourceClickHouse
(
"RemoteClickHouse"
,
"localhost"
,
"9000"
,
"clickhouse1"
,
"9000"
,
"default"
,
""
),
...
...
@@ -144,11 +145,11 @@ def test_simple_dictionaries(started_cluster):
Row
(
fields
,
[
1
,
22
,
333
,
4444
,
55555
,
-
6
,
-
77
,
-
888
,
-
999
,
'550e8400-e29b-41d4-a716-446655440003'
,
'1973-06-28'
,
'1985-02-28 23:43:25'
,
'hello'
,
22.543
,
3332154213.4
]),
'1973-06-28'
,
'1985-02-28 23:43:25'
,
'hello'
,
22.543
,
3332154213.4
,
0
]),
Row
(
fields
,
[
2
,
3
,
4
,
5
,
6
,
-
7
,
-
8
,
-
9
,
-
10
,
'550e8400-e29b-41d4-a716-446655440002'
,
'1978-06-28'
,
'1986-02-28 23:42:25'
,
'hello'
,
21.543
,
3222154213.4
]),
'1978-06-28'
,
'1986-02-28 23:42:25'
,
'hello'
,
21.543
,
3222154213.4
,
1
]),
]
simple_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"simple"
]
...
...
@@ -170,9 +171,22 @@ def test_simple_dictionaries(started_cluster):
for
query
in
dct
.
get_select_get_or_default_queries
(
field
,
row
):
queries_with_answers
.
append
((
query
,
field
.
default_value_for_get
))
for
query
in
dct
.
get_hierarchical_queries
(
data
[
0
]):
queries_with_answers
.
append
((
query
,
[
1
]))
for
query
in
dct
.
get_hierarchical_queries
(
data
[
1
]):
queries_with_answers
.
append
((
query
,
[
2
,
1
]))
for
query
in
dct
.
get_is_in_queries
(
data
[
0
],
data
[
1
]):
queries_with_answers
.
append
((
query
,
0
))
for
query
in
dct
.
get_is_in_queries
(
data
[
1
],
data
[
0
]):
queries_with_answers
.
append
((
query
,
1
))
for
query
,
answer
in
queries_with_answers
:
print
query
if
isinstance
(
answer
,
list
):
answer
=
str
(
answer
).
replace
(
' '
,
''
)
assert
node
.
query
(
query
)
==
str
(
answer
)
+
'
\n
'
def
test_complex_dictionaries
(
started_cluster
):
...
...
@@ -187,7 +201,7 @@ def test_complex_dictionaries(started_cluster):
[
2
,
'qwerty2'
,
52
,
2345
,
6544
,
9191991
,
-
2
,
-
717
,
-
81818
,
-
92929
,
'550e8400-e29b-41d4-a716-446655440007'
,
'1975-09-28'
,
'2000-02-28 23:33:24'
,
'my'
,
255.543
,
333222154213.
4
]),
'my'
,
255.543
,
3332221.4
4
]),
]
complex_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"complex"
]
...
...
@@ -225,10 +239,10 @@ def test_ranged_dictionaries(started_cluster):
22.543
,
3332154213.4
]),
Row
(
fields
,
[
1
,
'2019-04-10'
,
'2019-04-01'
,
'2019-04-28'
,
555
,
32323
,
414144
,
5255
515
,
-
65
,
-
747
,
-
8388
,
-
9099
,
11
,
3223
,
41444
,
52
515
,
-
65
,
-
747
,
-
8388
,
-
9099
,
'550e8400-e29b-41d4-a716-446655440004'
,
'1973-06-29'
,
'2002-02-28 23:23:25'
,
'!!!!'
,
32.543
,
3332
154551
3.4
]),
32.543
,
3332
54
3.4
]),
]
ranged_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"ranged"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录