diff --git a/src/Interpreters/JoinUtils.h b/src/Interpreters/JoinUtils.h index 77ecf38fa6b..8c1c60584d8 100644 --- a/src/Interpreters/JoinUtils.h +++ b/src/Interpreters/JoinUtils.h @@ -169,19 +169,4 @@ private: void setRightIndex(size_t right_pos, size_t result_position); }; -/// Call the same func twice - for left arguments and then right arguments -template -void forJoinSides(Func && func, std::tuple && left, std::tuple && right) -{ - std::apply([&](auto &&... args) - { - func(JoinTableSide::Left, std::forward(args)...); - }, std::forward>(left)); - - std::apply([&](auto &&... args) - { - func(JoinTableSide::Right, std::forward(args)...); - }, std::forward>(right)); -} - } diff --git a/src/Planner/PlannerJoinTree.cpp b/src/Planner/PlannerJoinTree.cpp index 5b66d831fc7..9a0408b52f6 100644 --- a/src/Planner/PlannerJoinTree.cpp +++ b/src/Planner/PlannerJoinTree.cpp @@ -1339,12 +1339,14 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_ const auto & left_pre_filters = join_clauses_and_actions.join_clauses[0].getLeftFilterConditionNodes(); const auto & right_pre_filters = join_clauses_and_actions.join_clauses[0].getRightFilterConditionNodes(); - forJoinSides([](JoinTableSide side, const auto & pre_filters) + auto check_pre_filter = [](JoinTableSide side, const auto & pre_filters) { if (!pre_filters.empty() && pre_filters.size() != 1) throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected only one {} pre-filter condition node. Actual [{}]", side, fmt::join(pre_filters | std::views::transform([](const auto & node) { return node->result_name; }), ", ")); - }, std::make_tuple(std::ref(left_pre_filters)), std::make_tuple(std::ref(right_pre_filters))); + }; + check_pre_filter(left_pre_filters); + check_pre_filter(right_pre_filters); can_move_out_residuals = join_clauses_and_actions.join_clauses.size() == 1 && join_strictness == JoinStrictness::All @@ -1352,7 +1354,7 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_ && (right_pre_filters.empty() || FilterStep::canUseType(right_pre_filters[0]->result_type)) && (left_pre_filters.empty() || FilterStep::canUseType(left_pre_filters[0]->result_type)); - forJoinSides([&](JoinTableSide, ActionsDAG & join_expressions_actions, QueryPlan & plan, const auto & pre_filters) + auto add_pre_filter = [&](JoinTableSide, ActionsDAG & join_expressions_actions, QueryPlan & plan, const auto & pre_filters) { join_expressions_actions.appendInputsForUnusedColumns(left_plan.getCurrentHeader()); appendSetsFromActionsDAG(join_expressions_actions, left_join_tree_query_plan.useful_sets); @@ -1365,8 +1367,9 @@ JoinTreeQueryPlan buildQueryPlanForJoinNode(const QueryTreeNodePtr & join_table_ join_expressions_actions_step->setStepDescription("JOIN actions"); plan.addStep(std::move(join_expressions_actions_step)); - }, std::make_tuple(std::ref(join_clauses_and_actions.left_join_expressions_actions), std::ref(left_plan), std::ref(left_pre_filters)), - std::make_tuple(std::ref(join_clauses_and_actions.right_join_expressions_actions), std::ref(right_plan), std::ref(right_pre_filters))); + }; + add_pre_filter(join_clauses_and_actions.left_join_expressions_actions, left_plan, left_pre_filters); + add_pre_filter(join_clauses_and_actions.right_join_expressions_actions, right_plan, right_pre_filters); } std::unordered_map left_plan_column_name_to_cast_type;