Improved column comments support

This commit is contained in:
Kostiantyn Storozhuk 2021-06-25 22:30:11 +08:00
parent 4fe722d1a4
commit ca04b077ef
2 changed files with 8 additions and 2 deletions

View File

@ -564,7 +564,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)
{
@ -658,7 +659,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())
{

View File

@ -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")