From edc9e8fbc8eb91e00399ab844681c95e31df0f70 Mon Sep 17 00:00:00 2001 From: vdimir Date: Fri, 22 Mar 2024 17:30:50 +0000 Subject: [PATCH 1/2] Analyzer: Fix assert in JOIN with Distributed table --- src/Planner/PlannerContext.cpp | 3 +++ src/Planner/PlannerJoinTree.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Planner/PlannerContext.cpp b/src/Planner/PlannerContext.cpp index f939b959ce7..c9187e6aa2a 100644 --- a/src/Planner/PlannerContext.cpp +++ b/src/Planner/PlannerContext.cpp @@ -32,6 +32,9 @@ const ColumnIdentifier & GlobalPlannerContext::createColumnIdentifier(const Name column_identifier = column.name; auto [it, inserted] = column_identifiers.emplace(column_identifier); + if (!inserted) + throw Exception(ErrorCodes::LOGICAL_ERROR, "Column identifier {} is already registered", column_identifier); + assert(inserted); return *it; diff --git a/src/Planner/PlannerJoinTree.cpp b/src/Planner/PlannerJoinTree.cpp index 61a7a19f5be..4ca8b6d7d48 100644 --- a/src/Planner/PlannerJoinTree.cpp +++ b/src/Planner/PlannerJoinTree.cpp @@ -960,7 +960,8 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres else { auto subquery_options = select_query_options.subquery(); - Planner subquery_planner(table_expression, subquery_options, planner_context->getGlobalPlannerContext()); + Planner subquery_planner(table_expression, subquery_options, + std::make_shared(nullptr, nullptr, FiltersForTableExpressionMap{})); /// Propagate storage limits to subquery subquery_planner.addStorageLimits(*select_query_info.storage_limits); subquery_planner.buildQueryPlanIfNeeded(); From f54e11176d6057f37c1f38e332d6ff5113accb50 Mon Sep 17 00:00:00 2001 From: vdimir Date: Fri, 22 Mar 2024 18:12:31 +0000 Subject: [PATCH 2/2] u --- src/Planner/PlannerJoinTree.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Planner/PlannerJoinTree.cpp b/src/Planner/PlannerJoinTree.cpp index 4ca8b6d7d48..c2b888af578 100644 --- a/src/Planner/PlannerJoinTree.cpp +++ b/src/Planner/PlannerJoinTree.cpp @@ -959,9 +959,14 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres } else { + std::shared_ptr subquery_planner_context; + if (wrap_read_columns_in_subquery) + subquery_planner_context = std::make_shared(nullptr, nullptr, FiltersForTableExpressionMap{}); + else + subquery_planner_context = planner_context->getGlobalPlannerContext(); + auto subquery_options = select_query_options.subquery(); - Planner subquery_planner(table_expression, subquery_options, - std::make_shared(nullptr, nullptr, FiltersForTableExpressionMap{})); + Planner subquery_planner(table_expression, subquery_options, subquery_planner_context); /// Propagate storage limits to subquery subquery_planner.addStorageLimits(*select_query_info.storage_limits); subquery_planner.buildQueryPlanIfNeeded();