This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 36ee16ebcf5 branch-4.1:[improvement](planner) Create ProcessState only
for plan-process tracing (#69055)
36ee16ebcf5 is described below
commit 36ee16ebcf5e70f4d95338d6f6e9aa8a8e20a309
Author: feiniaofeiafei <[email protected]>
AuthorDate: Thu Oct 15 09:27:51 2026 +0800
branch-4.1:[improvement](planner) Create ProcessState only for plan-process
tracing (#69055)
Port only the ProcessState changes from apache/doris#67797 Preserve
EXPLAIN PLAN PROCESS tracing and skip state maintenance for ordinary
queries.
---
.../nereids/jobs/rewrite/BottomUpVisitorRewriteJob.java | 15 ++++++---------
.../nereids/jobs/rewrite/TopDownVisitorRewriteJob.java | 12 +++++++-----
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/BottomUpVisitorRewriteJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/BottomUpVisitorRewriteJob.java
index 7bec8269ccf..2f8f257a9ed 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/BottomUpVisitorRewriteJob.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/BottomUpVisitorRewriteJob.java
@@ -57,9 +57,9 @@ public class BottomUpVisitorRewriteJob implements RewriteJob {
return;
}
- Plan root = rewrite(
- null, -1, originPlan, jobContext, rules,
batchId.incrementAndGet(), false, new ProcessState(originPlan)
- );
+ ProcessState processState =
jobContext.getCascadesContext().showPlanProcess()
+ ? new ProcessState(originPlan) : null;
+ Plan root = rewrite(null, -1, originPlan, jobContext, rules,
batchId.incrementAndGet(), false, processState);
jobContext.getCascadesContext().setRewritePlan(root);
}
@@ -75,9 +75,6 @@ public class BottomUpVisitorRewriteJob implements RewriteJob {
if (state == RewriteState.REWRITTEN) {
return plan;
}
- CascadesContext cascadesContext = jobContext.getCascadesContext();
- boolean showPlanProcess = cascadesContext.showPlanProcess();
-
Plan currentPlan = plan;
while (true) {
if (fastReturn &&
rules.getCurrentAndChildrenRules(currentPlan).isEmpty()) {
@@ -100,14 +97,14 @@ public class BottomUpVisitorRewriteJob implements
RewriteJob {
}
if (changed) {
currentPlan = currentPlan.withChildren(newChildren.build());
- if (showPlanProcess) {
+ if (processState != null) {
parent = processState.updateChild(parent, childIndex,
currentPlan);
}
}
Plan rewrittenPlan = doRewrite(parent, childIndex, currentPlan,
jobContext, rules, processState);
if (!rewrittenPlan.deepEquals(currentPlan)) {
currentPlan = rewrittenPlan;
- if (showPlanProcess) {
+ if (processState != null) {
parent = processState.updateChild(parent, childIndex,
currentPlan);
}
} else {
@@ -132,7 +129,7 @@ public class BottomUpVisitorRewriteJob implements
RewriteJob {
Plan result = transform.get(0);
currentRule.acceptPlan(result);
- if (cascadesContext.showPlanProcess()) {
+ if (processState != null) {
String beforeShape =
processState.getNewestPlan().treeString(true, plan);
String afterShape =
processState.updateChildAndGetNewest(originParent, childIndex, result)
.treeString(true, result);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/TopDownVisitorRewriteJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/TopDownVisitorRewriteJob.java
index 8ae29a77f47..bb07c113d23 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/TopDownVisitorRewriteJob.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/TopDownVisitorRewriteJob.java
@@ -53,9 +53,9 @@ public class TopDownVisitorRewriteJob implements RewriteJob {
return;
}
- Plan root = rewrite(
- null, -1, originPlan, jobContext, rules, false, new
ProcessState(originPlan)
- );
+ ProcessState processState =
jobContext.getCascadesContext().showPlanProcess()
+ ? new ProcessState(originPlan) : null;
+ Plan root = rewrite(null, -1, originPlan, jobContext, rules, false,
processState);
jobContext.getCascadesContext().setRewritePlan(root);
}
@@ -88,7 +88,9 @@ public class TopDownVisitorRewriteJob implements RewriteJob {
if (changed) {
plan = plan.withChildren(newChildren.build());
- processState.updateChild(parent, childIndex, plan);
+ if (processState != null) {
+ processState.updateChild(parent, childIndex, plan);
+ }
}
return plan;
@@ -113,7 +115,7 @@ public class TopDownVisitorRewriteJob implements RewriteJob
{
if (!transform.isEmpty() &&
!transform.get(0).deepEquals(originPlan)) {
Plan newPlan = transform.get(0);
currentRule.acceptPlan(originPlan);
- if (cascadesContext.showPlanProcess()) {
+ if (processState != null) {
String beforeShape =
processState.getNewestPlan().treeString(true, originPlan);
String afterShape =
processState.updateChildAndGetNewest(originParent, childIndex, newPlan)
.treeString(true, newPlan);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]