| 683 | } |
| 684 | |
| 685 | QueryTreeNodePtr extractLeftTableExpression(const QueryTreeNodePtr & join_tree_node) |
| 686 | { |
| 687 | QueryTreeNodePtr result; |
| 688 | |
| 689 | std::deque<QueryTreeNodePtr> nodes_to_process; |
| 690 | nodes_to_process.push_back(join_tree_node); |
| 691 | |
| 692 | while (!result) |
| 693 | { |
| 694 | auto node_to_process = std::move(nodes_to_process.front()); |
| 695 | nodes_to_process.pop_front(); |
| 696 | |
| 697 | auto node_type = node_to_process->getNodeType(); |
| 698 | |
| 699 | switch (node_type) |
| 700 | { |
| 701 | case QueryTreeNodeType::IDENTIFIER: |
| 702 | [[fallthrough]]; |
| 703 | case QueryTreeNodeType::TABLE: |
| 704 | [[fallthrough]]; |
| 705 | case QueryTreeNodeType::QUERY: |
| 706 | [[fallthrough]]; |
| 707 | case QueryTreeNodeType::UNION: |
| 708 | [[fallthrough]]; |
| 709 | case QueryTreeNodeType::TABLE_FUNCTION: |
| 710 | { |
| 711 | result = std::move(node_to_process); |
| 712 | break; |
| 713 | } |
| 714 | case QueryTreeNodeType::ARRAY_JOIN: |
| 715 | { |
| 716 | auto & array_join_node = node_to_process->as<ArrayJoinNode &>(); |
| 717 | nodes_to_process.push_front(array_join_node.getTableExpression()); |
| 718 | break; |
| 719 | } |
| 720 | case QueryTreeNodeType::CROSS_JOIN: |
| 721 | { |
| 722 | auto & cross_join_node = node_to_process->as<CrossJoinNode &>(); |
| 723 | nodes_to_process.push_front(cross_join_node.getTableExpressions().front()); |
| 724 | break; |
| 725 | } |
| 726 | case QueryTreeNodeType::JOIN: |
| 727 | { |
| 728 | auto & join_node = node_to_process->as<JoinNode &>(); |
| 729 | nodes_to_process.push_front(join_node.getLeftTableExpression()); |
| 730 | break; |
| 731 | } |
| 732 | default: |
| 733 | { |
| 734 | throw Exception(ErrorCodes::LOGICAL_ERROR, |
| 735 | "Unexpected node type for table expression. " |
| 736 | "Expected table, table function, query, union, join or array join. Actual {}", |
| 737 | node_to_process->getNodeTypeName()); |
| 738 | } |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | return result; |
no test coverage detected