From 80e9d7c45f4bdef9efb5c23822bc14e992650b5c Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Thu, 14 Dec 2023 14:51:38 +0000 Subject: [PATCH] Fix another case., --- src/Planner/PlannerJoins.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Planner/PlannerJoins.cpp b/src/Planner/PlannerJoins.cpp index d96d64fff0d..91d34258d61 100644 --- a/src/Planner/PlannerJoins.cpp +++ b/src/Planner/PlannerJoins.cpp @@ -301,12 +301,14 @@ void buildJoinClause( } else if (left_expression_side_optional && !right_expression_side_optional) { - const auto * node = appendExpression(left_dag, join_expression, planner_context, join_node); + auto & dag = *left_expression_side_optional == JoinTableSide::Left ? left_dag : right_dag; + const auto * node = appendExpression(dag, join_expression, planner_context, join_node); join_clause.addCondition(*left_expression_side_optional, node); } else if (!left_expression_side_optional && right_expression_side_optional) { - const auto * node = appendExpression(right_dag, join_expression, planner_context, join_node); + auto & dag = *right_expression_side_optional == JoinTableSide::Left ? left_dag : right_dag; + const auto * node = appendExpression(dag, join_expression, planner_context, join_node); join_clause.addCondition(*right_expression_side_optional, node); } else @@ -619,6 +621,11 @@ JoinClausesAndActions buildJoinClausesAndActions(//const ColumnsWithTypeAndName result.left_join_tmp_expression_actions = std::move(left_join_actions); result.left_join_expressions_actions->removeUnusedActions(join_left_actions_names); + // for (const auto & name : join_right_actions_names) + // std::cerr << ".. " << name << std::endl; + + // std::cerr << right_join_actions->dumpDAG() << std::endl; + result.right_join_expressions_actions = right_join_actions->clone(); result.right_join_tmp_expression_actions = std::move(right_join_actions); result.right_join_expressions_actions->removeUnusedActions(join_right_actions_names);