From a6bb4cdca04a063ee34e2d0f4d4827f06b7b42d8 Mon Sep 17 00:00:00 2001 From: minghong Date: Fri, 18 Oct 2024 17:21:35 +0800 Subject: [PATCH] fix --- .../nereids/processor/post/PlanPostProcessor.java | 4 +++- .../processor/post/RuntimeFilterPruner.java | 3 +++ .../trees/plans/visitor/DefaultPlanRewriter.java | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/PlanPostProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/PlanPostProcessor.java index 5090acedf43f395..f73d552ee82384d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/PlanPostProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/PlanPostProcessor.java @@ -19,6 +19,7 @@ import org.apache.doris.nereids.CascadesContext; import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.physical.AbstractPhysicalPlan; import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanRewriter; /** @@ -27,6 +28,7 @@ public class PlanPostProcessor extends DefaultPlanRewriter { public Plan processRoot(Plan plan, CascadesContext ctx) { - return plan.accept(this, ctx); + AbstractPhysicalPlan newPlan = (AbstractPhysicalPlan) super.visit(plan, ctx); + return newPlan == plan ? plan : newPlan.copyStatsAndGroupIdFrom((AbstractPhysicalPlan) plan); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java index 92b2960fb25c330..3fbaf927ed17026 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java @@ -284,6 +284,9 @@ private boolean isEffectiveRuntimeFilter(EqualTo equalTo, PhysicalHashJoin join) } Slot leftSlot = leftSlots.iterator().next(); Slot rightSlot = rightSlots.iterator().next(); + if (leftStats == null || rightStats == null) { + return false; + } ColumnStatistic probeColumnStat = leftStats.findColumnStatistics(leftSlot); ColumnStatistic buildColumnStat = rightStats.findColumnStatistics(rightSlot); //TODO remove these code when we ensure left child if from probe side 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 ff89572197df0bd..cf5d5f6bd13ed73 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,18 @@ public static

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