There is a special workaround for the case when ARRAY JOIN alias is used in USING statement. Example: ... ARRAY JOIN arr AS dummy INNER JOIN system.one USING (dummy); In case of ARRAY JOIN, the column is renamed, so the query tree will look like: JOIN EXPRESSION LIST COLUMN id: 16, column_name: dummy EXPRESSION LIST COLUMN id: 18, column_name: __array_join_exp_1 COLUMN id: 19, column_name: dummy
| 60 | /// |
| 61 | /// See 03448_analyzer_array_join_alias_in_join_using_bug |
| 62 | static ASTPtr tryMakeUsingColumnASTWithAlias(const QueryTreeNodePtr & node) |
| 63 | { |
| 64 | const auto * column_node = node->as<ColumnNode>(); |
| 65 | if (!column_node) |
| 66 | return nullptr; |
| 67 | |
| 68 | const auto & expr = column_node->getExpression(); |
| 69 | if (!expr) |
| 70 | return nullptr; |
| 71 | |
| 72 | const auto * expr_list_node = expr->as<ListNode>(); |
| 73 | if (!expr_list_node) |
| 74 | return nullptr; |
| 75 | |
| 76 | if (expr_list_node->getNodes().size() != 2) |
| 77 | return nullptr; |
| 78 | |
| 79 | const auto * lhs_column_node = expr_list_node->getNodes()[0]->as<ColumnNode>(); |
| 80 | const auto * rhs_column_node = expr_list_node->getNodes()[1]->as<ColumnNode>(); |
| 81 | if (!lhs_column_node || !rhs_column_node) |
| 82 | return nullptr; |
| 83 | |
| 84 | /// If USING column resolved from projection, keep its name |
| 85 | if (lhs_column_node->hasExpression()) |
| 86 | return nullptr; |
| 87 | |
| 88 | if (lhs_column_node->getColumnName() == rhs_column_node->getColumnName()) |
| 89 | return nullptr; |
| 90 | |
| 91 | auto node_ast = make_intrusive<ASTIdentifier>(lhs_column_node->getColumnName()); |
| 92 | node_ast->setAlias(rhs_column_node->getColumnName()); |
| 93 | return node_ast; |
| 94 | } |
| 95 | |
| 96 | static ASTPtr makeUsingAST(const QueryTreeNodePtr & node) |
| 97 | { |
no test coverage detected