Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
748b75ab
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,发现更多精彩内容 >>
未验证
提交
748b75ab
编写于
10月 12, 2020
作者:
T
tavplubix
提交者:
GitHub
10月 12, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15767 from ClickHouse/fix_materialize_mysql_count_v2
Try fix select count() for MaterializeMySQL (another way)
上级
2a62a91a
a6178cc8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
0 deletion
+58
-0
src/Storages/StorageMaterializeMySQL.cpp
src/Storages/StorageMaterializeMySQL.cpp
+11
-0
src/Storages/StorageMaterializeMySQL.h
src/Storages/StorageMaterializeMySQL.h
+1
-0
src/Storages/StorageMerge.cpp
src/Storages/StorageMerge.cpp
+8
-0
src/Storages/StorageMerge.h
src/Storages/StorageMerge.h
+1
-0
tests/integration/test_materialize_mysql_database/materialize_with_ddl.py
...n/test_materialize_mysql_database/materialize_with_ddl.py
+30
-0
tests/integration/test_materialize_mysql_database/test.py
tests/integration/test_materialize_mysql_database/test.py
+7
-0
未找到文件。
src/Storages/StorageMaterializeMySQL.cpp
浏览文件 @
748b75ab
...
...
@@ -105,6 +105,17 @@ NamesAndTypesList StorageMaterializeMySQL::getVirtuals() const
return
nested_storage
->
getVirtuals
();
}
IStorage
::
ColumnSizeByName
StorageMaterializeMySQL
::
getColumnSizes
()
const
{
auto
sizes
=
nested_storage
->
getColumnSizes
();
auto
nested_header
=
nested_storage
->
getInMemoryMetadataPtr
()
->
getSampleBlock
();
String
sign_column_name
=
nested_header
.
getByPosition
(
nested_header
.
columns
()
-
2
).
name
;
String
version_column_name
=
nested_header
.
getByPosition
(
nested_header
.
columns
()
-
1
).
name
;
sizes
.
erase
(
sign_column_name
);
sizes
.
erase
(
version_column_name
);
return
sizes
;
}
}
#endif
src/Storages/StorageMaterializeMySQL.h
浏览文件 @
748b75ab
...
...
@@ -26,6 +26,7 @@ public:
const
Context
&
context
,
QueryProcessingStage
::
Enum
processed_stage
,
size_t
max_block_size
,
unsigned
num_streams
)
override
;
NamesAndTypesList
getVirtuals
()
const
override
;
ColumnSizeByName
getColumnSizes
()
const
override
;
private:
StoragePtr
nested_storage
;
...
...
src/Storages/StorageMerge.cpp
浏览文件 @
748b75ab
...
...
@@ -538,6 +538,14 @@ void StorageMerge::convertingSourceStream(
}
}
IStorage
::
ColumnSizeByName
StorageMerge
::
getColumnSizes
()
const
{
auto
first_materialize_mysql
=
getFirstTable
([](
const
StoragePtr
&
table
)
{
return
table
&&
table
->
getName
()
==
"MaterializeMySQL"
;
});
if
(
!
first_materialize_mysql
)
return
{};
return
first_materialize_mysql
->
getColumnSizes
();
}
void
registerStorageMerge
(
StorageFactory
&
factory
)
{
...
...
src/Storages/StorageMerge.h
浏览文件 @
748b75ab
...
...
@@ -66,6 +66,7 @@ private:
DatabaseTablesIteratorPtr
getDatabaseIterator
(
const
Context
&
context
)
const
;
NamesAndTypesList
getVirtuals
()
const
override
;
ColumnSizeByName
getColumnSizes
()
const
override
;
protected:
StorageMerge
(
...
...
tests/integration/test_materialize_mysql_database/materialize_with_ddl.py
浏览文件 @
748b75ab
...
...
@@ -431,3 +431,33 @@ def query_event_with_empty_transaction(clickhouse_node, mysql_node, service_name
check_query
(
clickhouse_node
,
"SELECT * FROM test_database.t1 ORDER BY a FORMAT TSV"
,
"1
\t
BEGIN
\n
2
\t
BEGIN
\n
"
)
clickhouse_node
.
query
(
"DROP DATABASE test_database"
)
mysql_node
.
query
(
"DROP DATABASE test_database"
)
def
select_without_columns
(
clickhouse_node
,
mysql_node
,
service_name
):
mysql_node
.
query
(
"CREATE DATABASE db"
)
mysql_node
.
query
(
"CREATE TABLE db.t (a INT PRIMARY KEY, b INT)"
)
clickhouse_node
.
query
(
"CREATE DATABASE db ENGINE = MaterializeMySQL('{}:3306', 'db', 'root', 'clickhouse')"
.
format
(
service_name
))
check_query
(
clickhouse_node
,
"SHOW TABLES FROM db FORMAT TSV"
,
"t
\n
"
)
clickhouse_node
.
query
(
"SYSTEM STOP MERGES db.t"
)
clickhouse_node
.
query
(
"CREATE VIEW v AS SELECT * FROM db.t"
)
mysql_node
.
query
(
"INSERT INTO db.t VALUES (1, 1), (2, 2)"
)
mysql_node
.
query
(
"DELETE FROM db.t WHERE a=2;"
)
check_query
(
clickhouse_node
,
"SELECT count((_sign, _version)) FROM db.t FORMAT TSV"
,
"3
\n
"
)
assert
clickhouse_node
.
query
(
"SELECT count(_sign) FROM db.t FORMAT TSV"
)
==
"2
\n
"
assert
clickhouse_node
.
query
(
"SELECT count(_version) FROM db.t FORMAT TSV"
)
==
"2
\n
"
assert
clickhouse_node
.
query
(
"SELECT count() FROM db.t FORMAT TSV"
)
==
"1
\n
"
assert
clickhouse_node
.
query
(
"SELECT count(*) FROM db.t FORMAT TSV"
)
==
"1
\n
"
assert
clickhouse_node
.
query
(
"SELECT count() FROM (SELECT * FROM db.t) FORMAT TSV"
)
==
"1
\n
"
assert
clickhouse_node
.
query
(
"SELECT count() FROM v FORMAT TSV"
)
==
"1
\n
"
assert
clickhouse_node
.
query
(
"SELECT count() FROM merge('db', 't') FORMAT TSV"
)
==
"1
\n
"
assert
clickhouse_node
.
query
(
"SELECT count() FROM remote('localhost', 'db', 't') FORMAT TSV"
)
==
"1
\n
"
assert
clickhouse_node
.
query
(
"SELECT _part FROM db.t FORMAT TSV"
)
==
"0_1_1_0
\n
"
assert
clickhouse_node
.
query
(
"SELECT _part FROM remote('localhost', 'db', 't') FORMAT TSV"
)
==
"0_1_1_0
\n
"
clickhouse_node
.
query
(
"DROP VIEW v"
)
clickhouse_node
.
query
(
"DROP DATABASE db"
)
mysql_node
.
query
(
"DROP DATABASE db"
)
tests/integration/test_materialize_mysql_database/test.py
浏览文件 @
748b75ab
...
...
@@ -146,3 +146,10 @@ def test_materialize_database_ddl_with_empty_transaction_5_7(started_cluster, st
def
test_materialize_database_ddl_with_empty_transaction_8_0
(
started_cluster
,
started_mysql_8_0
):
materialize_with_ddl
.
query_event_with_empty_transaction
(
clickhouse_node
,
started_mysql_8_0
,
"mysql8_0"
)
def
test_select_without_columns_5_7
(
started_cluster
,
started_mysql_5_7
):
materialize_with_ddl
.
select_without_columns
(
clickhouse_node
,
started_mysql_5_7
,
"mysql1"
)
def
test_select_without_columns_8_0
(
started_cluster
,
started_mysql_8_0
):
materialize_with_ddl
.
select_without_columns
(
clickhouse_node
,
started_mysql_8_0
,
"mysql8_0"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录