diff --git a/src/Interpreters/MySQL/InterpretersMySQLDDLQuery.cpp b/src/Interpreters/MySQL/InterpretersMySQLDDLQuery.cpp index a7f5e84fad1..43f58b2dbcc 100644 --- a/src/Interpreters/MySQL/InterpretersMySQLDDLQuery.cpp +++ b/src/Interpreters/MySQL/InterpretersMySQLDDLQuery.cpp @@ -582,7 +582,8 @@ ASTs InterpreterAlterImpl::getRewrittenQueries( if (alter_command->type == MySQLParser::ASTAlterCommand::ADD_COLUMN) { 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) { @@ -676,7 +677,8 @@ ASTs InterpreterAlterImpl::getRewrittenQueries( if (!alter_command->old_name.empty()) 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()) { diff --git a/tests/integration/test_materialize_mysql_database/materialize_with_ddl.py b/tests/integration/test_materialize_mysql_database/materialize_with_ddl.py index 5b267a28321..3fd1cb0ecae 100644 --- a/tests/integration/test_materialize_mysql_database/materialize_with_ddl.py +++ b/tests/integration/test_materialize_mysql_database/materialize_with_ddl.py @@ -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") 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") + 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") mysql_node.query("DROP DATABASE materialize_with_column_comments_test")