From de30ec1d1dbc78a9973d1313bde131ceb090ce24 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 18 Sep 2024 16:51:18 +0000 Subject: [PATCH] Fixing prewhere. --- src/Planner/PlannerJoinTree.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Planner/PlannerJoinTree.cpp b/src/Planner/PlannerJoinTree.cpp index 6ac50bbc1e6..1e042765c3f 100644 --- a/src/Planner/PlannerJoinTree.cpp +++ b/src/Planner/PlannerJoinTree.cpp @@ -778,7 +778,18 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres auto & prewhere_info = table_expression_query_info.prewhere_info; const auto & prewhere_actions = table_expression_data.getPrewhereFilterActions(); - if (prewhere_actions) + std::vector> where_filters; + + if (prewhere_actions && select_query_options.build_logical_plan) + { + where_filters.emplace_back( + FilterDAGInfo{ + prewhere_actions->clone(), + prewhere_actions->getOutputs().at(0)->result_name, + true}, + "Prewhere"); + } + else if (prewhere_actions) { prewhere_info = std::make_shared(); prewhere_info->prewhere_actions = prewhere_actions->clone(); @@ -791,7 +802,6 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres const auto & columns_names = table_expression_data.getColumnNames(); - std::vector> where_filters; const auto add_filter = [&](FilterDAGInfo & filter_info, std::string description) { bool is_final = table_expression_query_info.table_expression_modifiers