Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
c47acef5
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,发现更多精彩内容 >>
未验证
提交
c47acef5
编写于
12月 12, 2019
作者:
A
alexey-milovidov
提交者:
GitHub
12月 12, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8163 from ClickHouse/dictionaries_ddl_on_cluster
Dictionaries ddl on cluster
上级
1bb14bb6
e7f5b92b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
112 addition
and
1 deletion
+112
-1
dbms/src/Interpreters/InterpreterCreateQuery.cpp
dbms/src/Interpreters/InterpreterCreateQuery.cpp
+3
-0
dbms/src/Parsers/ASTCreateQuery.cpp
dbms/src/Parsers/ASTCreateQuery.cpp
+2
-1
dbms/src/Parsers/ParserCreateQuery.cpp
dbms/src/Parsers/ParserCreateQuery.cpp
+9
-0
dbms/tests/integration/test_dictionary_ddl_on_cluster/__init__.py
...ts/integration/test_dictionary_ddl_on_cluster/__init__.py
+0
-0
dbms/tests/integration/test_dictionary_ddl_on_cluster/configs/config.d/clusters.xml
...t_dictionary_ddl_on_cluster/configs/config.d/clusters.xml
+28
-0
dbms/tests/integration/test_dictionary_ddl_on_cluster/configs/config.d/ddl.xml
...n/test_dictionary_ddl_on_cluster/configs/config.d/ddl.xml
+8
-0
dbms/tests/integration/test_dictionary_ddl_on_cluster/test.py
.../tests/integration/test_dictionary_ddl_on_cluster/test.py
+62
-0
未找到文件。
dbms/src/Interpreters/InterpreterCreateQuery.cpp
浏览文件 @
c47acef5
...
...
@@ -708,6 +708,9 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
BlockIO
InterpreterCreateQuery
::
createDictionary
(
ASTCreateQuery
&
create
)
{
if
(
!
create
.
cluster
.
empty
())
return
executeDDLQueryOnCluster
(
query_ptr
,
context
,
{
create
.
database
});
String
dictionary_name
=
create
.
table
;
String
database_name
=
!
create
.
database
.
empty
()
?
create
.
database
:
context
.
getCurrentDatabase
();
...
...
dbms/src/Parsers/ASTCreateQuery.cpp
浏览文件 @
c47acef5
...
...
@@ -234,7 +234,7 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
<<
(
if_not_exists
?
"IF NOT EXISTS "
:
""
)
<<
(
settings
.
hilite
?
hilite_none
:
""
)
<<
(
!
database
.
empty
()
?
backQuoteIfNeed
(
database
)
+
"."
:
""
)
<<
backQuoteIfNeed
(
table
);
formatOnCluster
(
settings
);
formatOnCluster
(
settings
);
}
else
{
...
...
@@ -242,6 +242,7 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
settings
.
ostr
<<
(
settings
.
hilite
?
hilite_keyword
:
""
)
<<
(
attach
?
"ATTACH "
:
"CREATE "
)
<<
"DICTIONARY "
<<
(
if_not_exists
?
"IF NOT EXISTS "
:
""
)
<<
(
settings
.
hilite
?
hilite_none
:
""
)
<<
(
!
database
.
empty
()
?
backQuoteIfNeed
(
database
)
+
"."
:
""
)
<<
backQuoteIfNeed
(
table
);
formatOnCluster
(
settings
);
}
if
(
as_table_function
)
...
...
dbms/src/Parsers/ParserCreateQuery.cpp
浏览文件 @
c47acef5
...
...
@@ -826,6 +826,7 @@ bool ParserCreateDictionaryQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, E
ParserKeyword
s_attach
(
"ATTACH"
);
ParserKeyword
s_dictionary
(
"DICTIONARY"
);
ParserKeyword
s_if_not_exists
(
"IF NOT EXISTS"
);
ParserKeyword
s_on
(
"ON"
);
ParserIdentifier
name_p
;
ParserToken
s_left_paren
(
TokenType
::
OpeningRoundBracket
);
ParserToken
s_right_paren
(
TokenType
::
ClosingRoundBracket
);
...
...
@@ -840,6 +841,7 @@ bool ParserCreateDictionaryQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, E
ASTPtr
name
;
ASTPtr
attributes
;
ASTPtr
dictionary
;
String
cluster_str
;
bool
attach
=
false
;
if
(
!
s_create
.
ignore
(
pos
,
expected
))
...
...
@@ -866,6 +868,12 @@ bool ParserCreateDictionaryQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, E
return
false
;
}
if
(
s_on
.
ignore
(
pos
,
expected
))
{
if
(
!
ASTQueryWithOnCluster
::
parse
(
pos
,
cluster_str
,
expected
))
return
false
;
}
if
(
!
attach
)
{
if
(
!
s_left_paren
.
ignore
(
pos
,
expected
))
...
...
@@ -894,6 +902,7 @@ bool ParserCreateDictionaryQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, E
query
->
if_not_exists
=
if_not_exists
;
query
->
set
(
query
->
dictionary_attributes_list
,
attributes
);
query
->
set
(
query
->
dictionary
,
dictionary
);
query
->
cluster
=
cluster_str
;
return
true
;
}
...
...
dbms/tests/integration/test_dictionary_ddl_on_cluster/__init__.py
0 → 100644
浏览文件 @
c47acef5
dbms/tests/integration/test_dictionary_ddl_on_cluster/configs/config.d/clusters.xml
0 → 100644
浏览文件 @
c47acef5
<yandex>
<remote_servers>
<cluster>
<shard>
<internal_replication>
true
</internal_replication>
<replica>
<host>
ch1
</host>
<port>
9000
</port>
</replica>
<replica>
<host>
ch2
</host>
<port>
9000
</port>
</replica>
</shard>
<shard>
<internal_replication>
true
</internal_replication>
<replica>
<host>
ch3
</host>
<port>
9000
</port>
</replica>
<replica>
<host>
ch4
</host>
<port>
9000
</port>
</replica>
</shard>
</cluster>
</remote_servers>
</yandex>
dbms/tests/integration/test_dictionary_ddl_on_cluster/configs/config.d/ddl.xml
0 → 100644
浏览文件 @
c47acef5
<yandex>
<distributed_ddl>
<path>
/clickhouse/task_queue/ddl
</path>
<max_tasks_in_queue>
10
</max_tasks_in_queue>
<task_max_lifetime>
3600
</task_max_lifetime>
<cleanup_delay_period>
5
</cleanup_delay_period>
</distributed_ddl>
</yandex>
dbms/tests/integration/test_dictionary_ddl_on_cluster/test.py
0 → 100644
浏览文件 @
c47acef5
import
pytest
from
helpers.cluster
import
ClickHouseCluster
from
helpers.client
import
QueryRuntimeException
cluster
=
ClickHouseCluster
(
__file__
)
ch1
=
cluster
.
add_instance
(
'ch1'
,
config_dir
=
"configs"
,
with_zookeeper
=
True
)
ch2
=
cluster
.
add_instance
(
'ch2'
,
config_dir
=
"configs"
,
with_zookeeper
=
True
)
ch3
=
cluster
.
add_instance
(
'ch3'
,
config_dir
=
"configs"
,
with_zookeeper
=
True
)
ch4
=
cluster
.
add_instance
(
'ch4'
,
config_dir
=
"configs"
,
with_zookeeper
=
True
)
@
pytest
.
fixture
(
scope
=
"module"
)
def
started_cluster
():
try
:
cluster
.
start
()
ch1
.
query
(
"CREATE TABLE sometbl ON CLUSTER 'cluster' (key UInt64, value String) ENGINE = MergeTree ORDER by key"
)
yield
cluster
finally
:
cluster
.
shutdown
()
def
test_dictionary_ddl_on_cluster
(
started_cluster
):
for
node
in
[
ch1
,
ch2
,
ch3
,
ch4
]:
assert
node
.
query
(
"SELECT count() from sometbl"
)
==
"0
\n
"
for
num
,
node
in
enumerate
([
ch1
,
ch2
,
ch3
,
ch4
]):
node
.
query
(
"insert into sometbl values ({}, '{}')"
.
format
(
num
,
node
.
name
))
ch1
.
query
(
"""
CREATE DICTIONARY somedict ON CLUSTER 'cluster' (
key UInt64,
value String
)
PRIMARY KEY key
LAYOUT(FLAT())
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'sometbl' DB 'default'))
LIFETIME(10)
"""
)
for
num
,
node
in
enumerate
([
ch1
,
ch2
,
ch3
,
ch4
]):
assert
node
.
query
(
"SELECT count() from sometbl"
)
==
"1
\n
"
assert
node
.
query
(
"SELECT dictGetString('default.somedict', 'value', toUInt64({}))"
.
format
(
num
))
==
node
.
name
+
'
\n
'
ch1
.
query
(
"DETACH DICTIONARY default.somedict ON CLUSTER 'cluster'"
)
for
node
in
[
ch1
,
ch2
,
ch3
,
ch4
]:
with
pytest
.
raises
(
QueryRuntimeException
):
node
.
query
(
"SELECT dictGetString('default.somedict', 'value', toUInt64(1))"
)
ch1
.
query
(
"ATTACH DICTIONARY default.somedict ON CLUSTER 'cluster'"
)
for
num
,
node
in
enumerate
([
ch1
,
ch2
,
ch3
,
ch4
]):
assert
node
.
query
(
"SELECT count() from sometbl"
)
==
"1
\n
"
assert
node
.
query
(
"SELECT dictGetString('default.somedict', 'value', toUInt64({}))"
.
format
(
num
))
==
node
.
name
+
'
\n
'
ch1
.
query
(
"DROP DICTIONARY default.somedict ON CLUSTER 'cluster'"
)
for
node
in
[
ch1
,
ch2
,
ch3
,
ch4
]:
with
pytest
.
raises
(
QueryRuntimeException
):
node
.
query
(
"SELECT dictGetString('default.somedict', 'value', toUInt64(1))"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录