-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Planner: planner without DAGQueryBlock
#5381
Changes from 36 commits
05fd9bd
0d7ef30
09a5e03
e5b8cda
1bda85a
c53dcff
8312b95
0676e16
353a68b
e97bb7b
f0f6d86
a9037af
8046f68
65a7e3e
69d672f
1b6064c
b5ff7cf
03a0ab5
4a25811
6e2dcc7
a098564
c13c26c
ec1d177
3c7d777
b1d82c6
2e83735
efe0b7d
228226f
c7ea33c
fab303d
345e110
271c83e
ce35f9d
23937bd
0a4b465
3140faa
00409a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,10 @@ void orderStreams( | |
bool enable_fine_grained_shuffle, | ||
const Context & context, | ||
const LoggerPtr & log); | ||
|
||
void executeCreatingSets( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. port from #5466 |
||
DAGPipeline & pipeline, | ||
const Context & context, | ||
size_t max_streams, | ||
const LoggerPtr & log); | ||
} // namespace DB |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ | |
#include <Flash/Planner/plans/PhysicalMockExchangeSender.h> | ||
#include <Flash/Planner/plans/PhysicalMockTableScan.h> | ||
#include <Flash/Planner/plans/PhysicalProjection.h> | ||
#include <Flash/Planner/plans/PhysicalSource.h> | ||
#include <Flash/Planner/plans/PhysicalTableScan.h> | ||
#include <Flash/Planner/plans/PhysicalTopN.h> | ||
#include <Flash/Planner/plans/PhysicalWindow.h> | ||
|
@@ -53,6 +52,16 @@ bool pushDownSelection(const PhysicalPlanNodePtr & plan, const String & executor | |
} | ||
return false; | ||
} | ||
|
||
void fillOrderForListBasedExecutors(DAGContext & dag_context, const PhysicalPlanNodePtr & root_node) | ||
{ | ||
auto & list_based_executors_order = dag_context.list_based_executors_order; | ||
PhysicalPlanVisitor::visitPostOrder(root_node, [&](const PhysicalPlanNodePtr & plan) { | ||
assert(plan); | ||
if (plan->isRecordProfileStreams()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likely? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But |
||
list_based_executors_order.push_back(plan->execId()); | ||
}); | ||
} | ||
} // namespace | ||
|
||
void PhysicalPlan::build(const tipb::DAGRequest * dag_request) | ||
|
@@ -93,6 +102,7 @@ void PhysicalPlan::build(const String & executor_id, const tipb::Executor * exec | |
break; | ||
case tipb::ExecType::TypeExchangeSender: | ||
{ | ||
buildFinalProjection(fmt::format("{}_", executor_id), true); | ||
if (unlikely(dagContext().isTest())) | ||
pushBack(PhysicalMockExchangeSender::build(executor_id, log, popBack())); | ||
else | ||
|
@@ -129,27 +139,13 @@ void PhysicalPlan::build(const String & executor_id, const tipb::Executor * exec | |
} | ||
case tipb::ExecType::TypeJoin: | ||
{ | ||
auto right = popBack(); | ||
auto left = popBack(); | ||
|
||
/// Both sides of the join need to have non-root-final-projection to ensure that | ||
/// there are no duplicate columns in the blocks on the build and probe sides. | ||
buildFinalProjection(fmt::format("{}_r_", executor_id), false); | ||
auto right = popBack(); | ||
|
||
/// After DAGQueryBlock removed, `dagContext().isTest() && right->tp() != PlanType::Source` | ||
/// and `dagContext().isTest() && right->tp() != PlanType::Source` will be removed. | ||
if (dagContext().isTest() && right->tp() != PlanType::Source) | ||
{ | ||
pushBack(right); | ||
buildFinalProjection(fmt::format("{}_r_", executor_id), false); | ||
right = popBack(); | ||
} | ||
|
||
if (dagContext().isTest() && right->tp() != PlanType::Source) | ||
{ | ||
pushBack(left); | ||
buildFinalProjection(fmt::format("{}_l_", executor_id), false); | ||
left = popBack(); | ||
} | ||
buildFinalProjection(fmt::format("{}_l_", executor_id), false); | ||
auto left = popBack(); | ||
|
||
pushBack(PhysicalJoin::build(context, executor_id, log, executor->join(), left, right)); | ||
break; | ||
|
@@ -199,29 +195,41 @@ PhysicalPlanNodePtr PhysicalPlan::popBack() | |
return back; | ||
} | ||
|
||
void PhysicalPlan::buildSource(const String & executor_id, const BlockInputStreams & source_streams) | ||
/// For MPP, root final projection has been added under PhysicalExchangeSender or PhysicalMockExchangeSender. | ||
/// For batchcop/cop that without PhysicalExchangeSender or PhysicalMockExchangeSender, We need to add root final projection. | ||
void PhysicalPlan::addRootFinalProjectionIfNeed() | ||
{ | ||
pushBack(PhysicalSource::build(executor_id, source_streams, log)); | ||
assert(root_node); | ||
if (root_node->tp() != PlanType::ExchangeSender && root_node->tp() != PlanType::MockExchangeSender) | ||
{ | ||
pushBack(root_node); | ||
buildFinalProjection(fmt::format("{}_", root_node->execId()), true); | ||
root_node = popBack(); | ||
} | ||
} | ||
|
||
void PhysicalPlan::outputAndOptimize() | ||
{ | ||
RUNTIME_ASSERT(!root_node, log, "root_node shoud be nullptr before `outputAndOptimize`"); | ||
RUNTIME_ASSERT(cur_plan_nodes.size() == 1, log, "There can only be one plan node output, but here are {}", cur_plan_nodes.size()); | ||
|
||
root_node = popBack(); | ||
addRootFinalProjectionIfNeed(); | ||
|
||
LOG_FMT_DEBUG( | ||
log, | ||
"build unoptimized physical plan: \n{}", | ||
toString()); | ||
|
||
root_node = optimize(context, root_node); | ||
root_node = optimize(context, root_node, log); | ||
LOG_FMT_DEBUG( | ||
log, | ||
"build optimized physical plan: \n{}", | ||
toString()); | ||
|
||
RUNTIME_ASSERT(root_node, log, "root_node shoudn't be nullptr after `outputAndOptimize`"); | ||
|
||
if (!dagContext().return_executor_id) | ||
fillOrderForListBasedExecutors(dagContext(), root_node); | ||
} | ||
|
||
String PhysicalPlan::toString() const | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored to their original