-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MaterializeMySQL Engine column comments support #25199
Merged
kssenii
merged 9 commits into
ClickHouse:master
from
sand6255:MySQL-column-comments-support
Jun 17, 2021
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6c9f701
Wip my sql column comments support (#1)
sand6255 3dc718f
style fixes
sand6255 b2ddc98
Update InterpretersMySQLDDLQuery.cpp
sand6255 d96478c
Integration test added and small fixes
sand6255 e1b82d8
Integration test added and small fixes
sand6255 74849bb
Update InterpretersMySQLDDLQuery.cpp
sand6255 46b230d
Update InterpretersMySQLDDLQuery.cpp
sand6255 0343c44
Trigger Build
sand6255 41d007a
Merge branch 'master' into MySQL-column-comments-support
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ TEST(MySQLCreateRewritten, ColumnsDataType) | |
|
||
EXPECT_EQ(queryToString(tryRewrittenCreateQuery( | ||
"CREATE TABLE `test_database`.`test_table_1`(`key` INT NOT NULL PRIMARY KEY, test " + test_type + " COMMENT 'test_comment' NOT NULL)", context_holder.context)), | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` " + mapped_type + | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` " + mapped_type + " COMMENT 'test_comment'" + | ||
MATERIALIZEMYSQL_TABLE_COLUMNS + ") ENGINE = " | ||
"ReplacingMergeTree(_version) PARTITION BY intDiv(key, 4294967) ORDER BY tuple(key)"); | ||
|
||
|
@@ -75,7 +75,7 @@ TEST(MySQLCreateRewritten, ColumnsDataType) | |
|
||
EXPECT_EQ(queryToString(tryRewrittenCreateQuery( | ||
"CREATE TABLE `test_database`.`test_table_1`(`key` INT NOT NULL PRIMARY KEY, test " + test_type + " COMMENT 'test_comment' UNSIGNED)", context_holder.context)), | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` Nullable(U" + mapped_type + ")" + | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` Nullable(U" + mapped_type + ")" + " COMMENT 'test_comment'" + | ||
MATERIALIZEMYSQL_TABLE_COLUMNS + ") ENGINE = " | ||
"ReplacingMergeTree(_version) PARTITION BY intDiv(key, 4294967) ORDER BY tuple(key)"); | ||
|
||
|
@@ -87,7 +87,7 @@ TEST(MySQLCreateRewritten, ColumnsDataType) | |
|
||
EXPECT_EQ(queryToString(tryRewrittenCreateQuery( | ||
"CREATE TABLE `test_database`.`test_table_1`(`key` INT NOT NULL PRIMARY KEY, test " + test_type + " COMMENT 'test_comment' UNSIGNED NOT NULL)", context_holder.context)), | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` U" + mapped_type + | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` U" + mapped_type + " COMMENT 'test_comment'" + | ||
MATERIALIZEMYSQL_TABLE_COLUMNS + ") ENGINE = " | ||
"ReplacingMergeTree(_version) PARTITION BY intDiv(key, 4294967) ORDER BY tuple(key)"); | ||
} | ||
|
@@ -223,3 +223,15 @@ TEST(MySQLCreateRewritten, UniqueKeysConvert) | |
std::string(MATERIALIZEMYSQL_TABLE_COLUMNS) + | ||
") ENGINE = ReplacingMergeTree(_version) PARTITION BY intDiv(id, 18446744073709551) ORDER BY (code, name, tenant_id, id)"); | ||
} | ||
|
||
TEST(MySQLCreateRewritten, QueryWithColumnComments) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be you can also make integration test in |
||
{ | ||
tryRegisterFunctions(); | ||
const auto & context_holder = getContext(); | ||
|
||
EXPECT_EQ(queryToString(tryRewrittenCreateQuery( | ||
"CREATE TABLE `test_database`.`test_table_1`(`key` INT NOT NULL PRIMARY KEY, `test` INT COMMENT 'test_comment')", context_holder.context)), | ||
"CREATE TABLE test_database.test_table_1 (`key` Int32, `test` Nullable(Int32) COMMENT 'test_comment'" + | ||
std::string(MATERIALIZEMYSQL_TABLE_COLUMNS) + | ||
") ENGINE = ReplacingMergeTree(_version) PARTITION BY intDiv(key, 4294967) ORDER BY tuple(key)"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a little over-complicated given that
column_name_and_type
was actually initialized asgetColumnsList(columns_definition)
a few line before call to thisgetColumnsDescription
.It could be simpler to first create
columns_description
(by using implementation ofgetColumnsList
plus one check forcomment
incolumn_options
- there are already such checks for other options so it will be a more correct place for that, and returning columns_description there instead) and then getcolumns_name_and_type
fromcolumns_description->getAllPhysical()
.But I think it is also ok to leave your variant if you really want..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was what I tried initially. Problem for this implementation is modifying type in
GetKeys
(modifyPrimaryKeysToNonNullable
) forColumnsDescription
, since there is no good way (or I didn't found it) to change internalColumnDescription
by iterator.So in my implementation
columns_name_and_type
is mostly needed to create final types and names for columns, to later initialize descriptions from them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, why there is a problem with
getKeys
- I was suggesting to only modifygetColumnsList
to returnColumnsDescription
, instead ofNameAndTypesList
. And on the next line to getcolumns_with_type_and_name
viacolumns_description->getAllPhysical()
. All other methods will still usecolumns_with_type_and_name
. This will simplify the code a lot and there will be no need forgetColumnsDescriptionFromList
method, which actually does the same thing, which is done ingetColumnsList
but for other column features.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
getKeys
changescolumns_with_type_and_name
that we generate withgetColumnsList
, and if we just modifygetColumnsList
to returnColumnsDescription
- we will miss this changes in our descriptions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I agree.
By the way, lets rename
getColumnsDescriptionFromList
->createColumnsDescription