From cd5f9d7ce79f26f09136db0010137b5c882bc276 Mon Sep 17 00:00:00 2001 From: minghong Date: Tue, 22 Oct 2024 21:22:43 +0800 Subject: [PATCH] [fix](nereids)reserve stats and groupId on rewriting plan node (#42140) ## Proposed changes when node is rewriten, stats and group Id is removed this pr try to keep them Issue Number: close #xxx --- .../trees/plans/visitor/DefaultPlanRewriter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/DefaultPlanRewriter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/DefaultPlanRewriter.java index ff89572197df0b..3a30191d2c020b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/DefaultPlanRewriter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/DefaultPlanRewriter.java @@ -18,6 +18,7 @@ package org.apache.doris.nereids.trees.plans.visitor; import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.physical.AbstractPhysicalPlan; import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan; import org.apache.doris.nereids.trees.plans.physical.PhysicalStorageLayerAggregate; @@ -56,6 +57,15 @@ public static

P visitChildren(DefaultPlanRewriter rewrite } newChildren.add(newChild); } - return hasNewChildren ? (P) plan.withChildren(newChildren.build()) : plan; + + if (hasNewChildren) { + plan = (P) plan.withChildren(newChildren.build()); + if (plan instanceof AbstractPhysicalPlan) { + AbstractPhysicalPlan physicalPlan = (AbstractPhysicalPlan) plan; + plan = (P) ((AbstractPhysicalPlan) physicalPlan.withChildren(newChildren.build())) + .copyStatsAndGroupIdFrom(physicalPlan); + } + } + return plan; } }