This commit is contained in:
Igor Nikonov 2024-11-04 22:37:57 +00:00
parent a6b55563c7
commit 8c5ab63345
4 changed files with 2 additions and 30 deletions

View File

@ -1263,7 +1263,6 @@ Planner::Planner(const QueryTreeNodePtr & query_tree_,
findQueryForParallelReplicas(query_tree, select_query_options),
findTableForParallelReplicas(query_tree, select_query_options),
collectFiltersForAnalysis(query_tree, select_query_options))))
// , root_planner(true)
{
}
@ -1538,7 +1537,7 @@ void Planner::buildPlanForQueryNode()
JoinTreeQueryPlan join_tree_query_plan;
if (planner_context->getMutableQueryContext()->canUseTaskBasedParallelReplicas()
&& planner_context->getGlobalPlannerContext()->parallel_replicas_node == &query_node /* && !root_planner*/)
&& planner_context->getGlobalPlannerContext()->parallel_replicas_node == &query_node)
{
join_tree_query_plan = buildQueryPlanForParallelReplicas(query_node, planner_context, select_query_info.storage_limits);
}

View File

@ -82,7 +82,6 @@ private:
StorageLimitsList storage_limits;
std::set<std::string> used_row_policies;
QueryNodeToPlanStepMapping query_node_to_plan_step_mapping;
// bool root_planner = false;
};
}

View File

@ -669,12 +669,6 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres
auto query_context = planner_context->getQueryContext();
const auto & settings = query_context->getSettingsRef();
LOG_DEBUG(
getLogger(__PRETTY_FUNCTION__),
"pr_enabled={} table_expression:\n{}",
settings[Setting::allow_experimental_parallel_reading_from_replicas].toString(),
table_expression->dumpTree());
auto & table_expression_data = planner_context->getTableExpressionDataOrThrow(table_expression);
QueryProcessingStage::Enum from_stage = QueryProcessingStage::Enum::FetchColumns;

View File

@ -265,18 +265,11 @@ const QueryNode * findQueryForParallelReplicas(const QueryTreeNodePtr & query_tr
auto stack = getSupportingParallelReplicasQuery(query_tree_node.get());
/// Empty stack means that storage does not support parallel replicas.
if (stack.empty())
{
// LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Not found");
return nullptr;
}
/// We don't have any subquery and storage can process parallel replicas by itself.
if (stack.top() == query_tree_node.get())
{
// LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Query itself:\n{}", query_tree_node->dumpTree());
return nullptr;
// return query_node;
}
/// This is needed to avoid infinite recursion.
auto mutable_context = Context::createCopy(context);
@ -310,17 +303,11 @@ const QueryNode * findQueryForParallelReplicas(const QueryTreeNodePtr & query_tr
new_stack.pop();
}
}
// if (!res)
// LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Not found 2");
// else
// LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Query:\n{}", query_tree_node->dumpTree());
return res;
}
static const TableNode * findTableForParallelReplicas(const IQueryTreeNode * query_tree_node)
{
LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "\n{}", StackTrace().toString());
std::stack<const IQueryTreeNode *> join_nodes;
while (query_tree_node || !join_nodes.empty())
{
@ -426,12 +413,7 @@ const TableNode * findTableForParallelReplicas(const QueryTreeNodePtr & query_tr
if (!context->canUseParallelReplicasOnFollower())
return nullptr;
const auto * res = findTableForParallelReplicas(query_tree_node.get());
// if (res)
// LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Table found {}", res->getStorageID().getFullTableName());
// else
// LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Not table found");
return res;
return findTableForParallelReplicas(query_tree_node.get());
}
JoinTreeQueryPlan buildQueryPlanForParallelReplicas(
@ -439,8 +421,6 @@ JoinTreeQueryPlan buildQueryPlanForParallelReplicas(
const PlannerContextPtr & planner_context,
std::shared_ptr<const StorageLimitsList> storage_limits)
{
LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "\n{}", StackTrace().toString());
auto processed_stage = QueryProcessingStage::WithMergeableState;
auto context = planner_context->getQueryContext();