diff --git a/src/Planner/CollectTableExpressionData.cpp b/src/Planner/CollectTableExpressionData.cpp index 492120141a4..4c48202af0b 100644 --- a/src/Planner/CollectTableExpressionData.cpp +++ b/src/Planner/CollectTableExpressionData.cpp @@ -77,12 +77,12 @@ public: { /// Replace ALIAS column with expression bool column_already_exists = table_expression_data.hasColumn(column_node->getColumnName()); - if (column_already_exists) - return; + if (!column_already_exists) + { + auto column_identifier = planner_context.getGlobalPlannerContext()->createColumnIdentifier(node); + table_expression_data.addAliasColumnName(column_node->getColumnName(), column_identifier); + } - auto column_identifier = planner_context.getGlobalPlannerContext()->createColumnIdentifier(node); - - table_expression_data.addAliasColumnName(column_node->getColumnName(), column_identifier); node = column_node->getExpression(); visitImpl(node); return;