mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #25781 from sand6255/MaterializeMySQL-Engine-column-comments-improvement
MaterializeMySQL: Improved column comments support
This commit is contained in:
commit
d9c46003cb
@ -582,7 +582,8 @@ ASTs InterpreterAlterImpl::getRewrittenQueries(
|
|||||||
if (alter_command->type == MySQLParser::ASTAlterCommand::ADD_COLUMN)
|
if (alter_command->type == MySQLParser::ASTAlterCommand::ADD_COLUMN)
|
||||||
{
|
{
|
||||||
const auto & additional_columns_name_and_type = getColumnsList(alter_command->additional_columns);
|
const auto & additional_columns_name_and_type = getColumnsList(alter_command->additional_columns);
|
||||||
const auto & additional_columns = InterpreterCreateQuery::formatColumns(additional_columns_name_and_type);
|
const auto & additional_columns_description = createColumnsDescription(additional_columns_name_and_type, alter_command->additional_columns);
|
||||||
|
const auto & additional_columns = InterpreterCreateQuery::formatColumns(additional_columns_description);
|
||||||
|
|
||||||
for (size_t index = 0; index < additional_columns_name_and_type.size(); ++index)
|
for (size_t index = 0; index < additional_columns_name_and_type.size(); ++index)
|
||||||
{
|
{
|
||||||
@ -676,7 +677,8 @@ ASTs InterpreterAlterImpl::getRewrittenQueries(
|
|||||||
if (!alter_command->old_name.empty())
|
if (!alter_command->old_name.empty())
|
||||||
modify_columns.front().name = alter_command->old_name;
|
modify_columns.front().name = alter_command->old_name;
|
||||||
|
|
||||||
rewritten_command->col_decl = InterpreterCreateQuery::formatColumns(modify_columns)->children[0];
|
const auto & modify_columns_description = createColumnsDescription(modify_columns, alter_command->additional_columns);
|
||||||
|
rewritten_command->col_decl = InterpreterCreateQuery::formatColumns(modify_columns_description)->children[0];
|
||||||
|
|
||||||
if (!alter_command->column_name.empty())
|
if (!alter_command->column_name.empty())
|
||||||
{
|
{
|
||||||
|
@ -850,6 +850,10 @@ def materialize_with_column_comments_test(clickhouse_node, mysql_node, service_n
|
|||||||
mysql_node.query("CREATE TABLE materialize_with_column_comments_test.test (id int NOT NULL PRIMARY KEY, value VARCHAR(255) COMMENT 'test comment') ENGINE=InnoDB")
|
mysql_node.query("CREATE TABLE materialize_with_column_comments_test.test (id int NOT NULL PRIMARY KEY, value VARCHAR(255) COMMENT 'test comment') ENGINE=InnoDB")
|
||||||
clickhouse_node.query("CREATE DATABASE materialize_with_column_comments_test ENGINE = MaterializeMySQL('{}:3306', 'materialize_with_column_comments_test', 'root', 'clickhouse')".format(service_name))
|
clickhouse_node.query("CREATE DATABASE materialize_with_column_comments_test ENGINE = MaterializeMySQL('{}:3306', 'materialize_with_column_comments_test', 'root', 'clickhouse')".format(service_name))
|
||||||
check_query(clickhouse_node, "DESCRIBE TABLE materialize_with_column_comments_test.test", "id\tInt32\t\t\t\t\t\nvalue\tNullable(String)\t\t\ttest comment\t\t\n_sign\tInt8\tMATERIALIZED\t1\t\t\t\n_version\tUInt64\tMATERIALIZED\t1\t\t\t\n")
|
check_query(clickhouse_node, "DESCRIBE TABLE materialize_with_column_comments_test.test", "id\tInt32\t\t\t\t\t\nvalue\tNullable(String)\t\t\ttest comment\t\t\n_sign\tInt8\tMATERIALIZED\t1\t\t\t\n_version\tUInt64\tMATERIALIZED\t1\t\t\t\n")
|
||||||
|
mysql_node.query("ALTER TABLE materialize_with_column_comments_test.test MODIFY value VARCHAR(255) COMMENT 'comment test'")
|
||||||
|
check_query(clickhouse_node, "DESCRIBE TABLE materialize_with_column_comments_test.test", "id\tInt32\t\t\t\t\t\nvalue\tNullable(String)\t\t\tcomment test\t\t\n_sign\tInt8\tMATERIALIZED\t1\t\t\t\n_version\tUInt64\tMATERIALIZED\t1\t\t\t\n")
|
||||||
|
mysql_node.query("ALTER TABLE materialize_with_column_comments_test.test ADD value2 int COMMENT 'test comment 2'")
|
||||||
|
check_query(clickhouse_node, "DESCRIBE TABLE materialize_with_column_comments_test.test", "id\tInt32\t\t\t\t\t\nvalue\tNullable(String)\t\t\tcomment test\t\t\nvalue2\tNullable(Int32)\t\t\ttest comment 2\t\t\n_sign\tInt8\tMATERIALIZED\t1\t\t\t\n_version\tUInt64\tMATERIALIZED\t1\t\t\t\n")
|
||||||
clickhouse_node.query("DROP DATABASE materialize_with_column_comments_test")
|
clickhouse_node.query("DROP DATABASE materialize_with_column_comments_test")
|
||||||
mysql_node.query("DROP DATABASE materialize_with_column_comments_test")
|
mysql_node.query("DROP DATABASE materialize_with_column_comments_test")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user