diff --git a/src/Analyzer/createUniqueAliasesIfNecessary.cpp b/src/Analyzer/createUniqueAliasesIfNecessary.cpp index 7a56cf07048..fa2ccb09e43 100644 --- a/src/Analyzer/createUniqueAliasesIfNecessary.cpp +++ b/src/Analyzer/createUniqueAliasesIfNecessary.cpp @@ -176,14 +176,12 @@ private: { if (result.empty()) { - String unique_array_join_name = fmt::format("__array_join_{}", ++next_id); - for (auto & array_join_expression : array_join->getJoinExpressions()) { auto * array_join_column = array_join_expression->as(); chassert(array_join_column != nullptr); - String unique_expression_name = fmt::format("{}.{}", unique_array_join_name, array_join_column->getColumnName()); + String unique_expression_name = fmt::format("__array_join_exp_{}", ++next_id); result.emplace(array_join_column->getColumnName(), unique_expression_name); auto replacement_column = array_join_column->getColumn(); diff --git a/tests/queries/0_stateless/01655_plan_optimizations.reference b/tests/queries/0_stateless/01655_plan_optimizations.reference index d79c408f1a4..eb13997f0d1 100644 --- a/tests/queries/0_stateless/01655_plan_optimizations.reference +++ b/tests/queries/0_stateless/01655_plan_optimizations.reference @@ -121,8 +121,8 @@ Filter column: and(notEquals(y, 2), notEquals(x, 0)) ARRAY JOIN x Filter column: notEquals(y, 2) > (analyzer) filter is split, one part is filtered before ARRAY JOIN -Filter column: and(notEquals(__table2.y, 2_UInt8), notEquals(__array_join_1.x, 0_UInt8)) -ARRAY JOIN __array_join_1.x +Filter column: and(notEquals(__table2.y, 2_UInt8), notEquals(__array_join_exp_1, 0_UInt8)) +ARRAY JOIN __array_join_exp_1 Filter column: notEquals(__table2.y, 2_UInt8) 1 3 > filter is pushed down before Distinct diff --git a/tests/queries/0_stateless/01655_plan_optimizations.sh b/tests/queries/0_stateless/01655_plan_optimizations.sh index 622f71f00df..1a283a3027b 100755 --- a/tests/queries/0_stateless/01655_plan_optimizations.sh +++ b/tests/queries/0_stateless/01655_plan_optimizations.sh @@ -134,7 +134,7 @@ $CLICKHOUSE_CLIENT --enable_analyzer=1 -q " explain actions = 1 select x, y from ( select range(number) as x, number + 1 as y from numbers(3) ) array join x where y != 2 and x != 0" | - grep -o "Filter column: and(notEquals(__table2.y, 2_UInt8), notEquals(__array_join_1.x, 0_UInt8))\|ARRAY JOIN __array_join_1.x\|Filter column: notEquals(__table2.y, 2_UInt8)" + grep -o "Filter column: and(notEquals(__table2.y, 2_UInt8), notEquals(__array_join_exp_1, 0_UInt8))\|ARRAY JOIN __array_join_exp_1\|Filter column: notEquals(__table2.y, 2_UInt8)" $CLICKHOUSE_CLIENT -q " select x, y from ( select range(number) as x, number + 1 as y from numbers(3)