diff --git a/src/Interpreters/InterpreterCreateQuery.cpp b/src/Interpreters/InterpreterCreateQuery.cpp index 01eedca2184..f3ef1e3359e 100644 --- a/src/Interpreters/InterpreterCreateQuery.cpp +++ b/src/Interpreters/InterpreterCreateQuery.cpp @@ -453,14 +453,6 @@ ASTPtr InterpreterCreateQuery::formatColumns(const ColumnsDescription & columns) column_declaration->children.push_back(column_declaration->codec); } - if (!column.settings.empty()) - { - auto per_column_settings = std::make_shared(); - per_column_settings->is_standalone = false; - per_column_settings->changes = column.settings; - column_declaration->per_column_settings = std::move(per_column_settings); - } - if (column.stat) { column_declaration->stat_type = column.stat->ast; @@ -473,6 +465,14 @@ ASTPtr InterpreterCreateQuery::formatColumns(const ColumnsDescription & columns) column_declaration->children.push_back(column_declaration->ttl); } + if (!column.settings.empty()) + { + auto per_column_settings = std::make_shared(); + per_column_settings->is_standalone = false; + per_column_settings->changes = column.settings; + column_declaration->per_column_settings = std::move(per_column_settings); + } + columns_list->children.push_back(column_declaration_ptr); } diff --git a/src/Parsers/ASTColumnDeclaration.cpp b/src/Parsers/ASTColumnDeclaration.cpp index 196780ccf29..dd3bf6ae8d8 100644 --- a/src/Parsers/ASTColumnDeclaration.cpp +++ b/src/Parsers/ASTColumnDeclaration.cpp @@ -39,12 +39,6 @@ ASTPtr ASTColumnDeclaration::clone() const res->children.push_back(res->codec); } - if (per_column_settings) - { - res->per_column_settings = per_column_settings->clone(); - res->children.push_back(res->per_column_settings); - } - if (stat_type) { res->stat_type = stat_type->clone(); @@ -63,6 +57,12 @@ ASTPtr ASTColumnDeclaration::clone() const res->children.push_back(res->collation); } + if (per_column_settings) + { + res->per_column_settings = per_column_settings->clone(); + res->children.push_back(res->per_column_settings); + } + return res; }