Skip to content

Commit

Permalink
copy stats and groupId when rewrite physical plan
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Oct 18, 2024
1 parent cec0458 commit 651881d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -27,6 +28,7 @@
public class PlanPostProcessor extends DefaultPlanRewriter<CascadesContext> {

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -56,6 +57,14 @@ public static <P extends Plan, C> P visitChildren(DefaultPlanRewriter<C> 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;
}
}

0 comments on commit 651881d

Please sign in to comment.