StorageDistributed Planner initialization fix

This commit is contained in:
Maksim Kita 2023-01-24 19:15:41 +01:00
parent d3b604de5a
commit 25da9dcef7
3 changed files with 27 additions and 2 deletions

View File

@ -959,6 +959,17 @@ Planner::Planner(const QueryTreeNodePtr & query_tree_,
{ {
} }
Planner::Planner(const QueryTreeNodePtr & query_tree_,
const SelectQueryOptions & select_query_options_,
PlannerContextPtr planner_context_,
PlannerConfiguration planner_configuration_)
: query_tree(query_tree_)
, select_query_options(select_query_options_)
, planner_context(std::move(planner_context_))
, planner_configuration(std::move(planner_configuration_))
{
}
void Planner::buildQueryPlanIfNeeded() void Planner::buildQueryPlanIfNeeded()
{ {
if (query_plan.isInitialized()) if (query_plan.isInitialized())

View File

@ -35,6 +35,12 @@ public:
GlobalPlannerContextPtr global_planner_context_, GlobalPlannerContextPtr global_planner_context_,
PlannerConfiguration planner_configuration_ = {}); PlannerConfiguration planner_configuration_ = {});
/// Initialize planner with query tree after query analysis phase and planner context
Planner(const QueryTreeNodePtr & query_tree_,
const SelectQueryOptions & select_query_options_,
PlannerContextPtr planner_context_,
PlannerConfiguration planner_configuration_ = {});
const QueryPlan & getQueryPlan() const const QueryPlan & getQueryPlan() const
{ {
return query_plan; return query_plan;

View File

@ -663,8 +663,12 @@ void StorageDistributed::read(
StorageID remote_storage_id{remote_database, remote_table}; StorageID remote_storage_id{remote_database, remote_table};
auto query_tree_with_replaced_distributed_table = buildQueryTreeDistributedTableReplacedWithLocalTable(query_info, remote_storage_id); auto query_tree_with_replaced_distributed_table = buildQueryTreeDistributedTableReplacedWithLocalTable(query_info, remote_storage_id);
query_ast = queryNodeToSelectQuery(query_tree_with_replaced_distributed_table); query_ast = queryNodeToSelectQuery(query_tree_with_replaced_distributed_table);
Planner planner(query_tree_with_replaced_distributed_table, SelectQueryOptions(processed_stage), PlannerConfiguration{.only_analyze = true});
Planner planner(query_tree_with_replaced_distributed_table,
SelectQueryOptions(processed_stage),
PlannerConfiguration{.only_analyze = true});
planner.buildQueryPlanIfNeeded(); planner.buildQueryPlanIfNeeded();
header = planner.getQueryPlan().getCurrentDataStream().header; header = planner.getQueryPlan().getCurrentDataStream().header;
} }
else else
@ -716,8 +720,12 @@ void StorageDistributed::read(
if (local_context->getSettingsRef().allow_experimental_analyzer) if (local_context->getSettingsRef().allow_experimental_analyzer)
{ {
Planner planner(query_info.query_tree, SelectQueryOptions(processed_stage), PlannerConfiguration{.only_analyze = true}); Planner planner(query_info.query_tree,
SelectQueryOptions(processed_stage),
query_info.planner_context,
PlannerConfiguration{.only_analyze = true});
planner.buildQueryPlanIfNeeded(); planner.buildQueryPlanIfNeeded();
auto expected_header = planner.getQueryPlan().getCurrentDataStream().header; auto expected_header = planner.getQueryPlan().getCurrentDataStream().header;
auto rename_actions_dag = ActionsDAG::makeConvertingActions( auto rename_actions_dag = ActionsDAG::makeConvertingActions(