Skip to content

Commit

Permalink
[fix](nereids): fix PlanPostProcessor use visitor (#35244) (#35265)
Browse files Browse the repository at this point in the history
(cherry picked from commit 46e004a)
  • Loading branch information
jackwener authored May 23, 2024
1 parent ca57582 commit e4c3533
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
public class AddOffsetIntoDistribute extends PlanPostProcessor {
@Override
public Plan visitPhysicalLimit(PhysicalLimit<? extends Plan> limit, CascadesContext context) {
limit = (PhysicalLimit<? extends Plan>) super.visit(limit, context);
if (limit.getPhase().isLocal() || limit.getOffset() == 0) {
return limit;
}

return new PhysicalDistribute<>(DistributionSpecGather.INSTANCE,
limit.withLimit(limit.getLimit() + limit.getOffset()));
limit.withLimit(limit.getLimit() + limit.getOffset())).copyStatsAndGroupIdFrom(limit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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.physical.PhysicalFilter;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.util.ExpressionUtils;
Expand All @@ -30,15 +29,10 @@
public class PushdownFilterThroughProject extends PlanPostProcessor {
@Override
public Plan visitPhysicalFilter(PhysicalFilter<? extends Plan> filter, CascadesContext context) {
filter = (PhysicalFilter<? extends Plan>) super.visit(filter, context);
Plan child = filter.child();
if (!(child instanceof PhysicalProject)) {
Plan newChild = child.accept(this, context);
if (newChild == child) {
return filter;
} else {
return ((AbstractPhysicalPlan) filter.withChildren(child.accept(this, context)))
.copyStatsAndGroupIdFrom(filter);
}
return filter;
}

PhysicalProject<? extends Plan> project = (PhysicalProject<? extends Plan>) child;
Expand Down

0 comments on commit e4c3533

Please sign in to comment.