Skip to content

Commit

Permalink
[fix](Nereids) top-n with top project should hit top-n opt (#29971)
Browse files Browse the repository at this point in the history
in PR #29312, we limit top-n opt only enable in simplest cases.
in this PR, we let go of some restrictions.
  • Loading branch information
morrySnow authored and Doris-Extras committed Jan 16, 2024
1 parent 9e30a67 commit b99b9ef
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public Plan visit(Plan plan, CascadesContext context) {
public Plan visitPhysicalSink(PhysicalSink<? extends Plan> physicalSink, CascadesContext context) {
if (physicalSink.child() instanceof TopN) {
return super.visit(physicalSink, context);
} else if (physicalSink.child() instanceof Project && physicalSink.child().child(0) instanceof TopN) {
PhysicalTopN<?> oldTopN = (PhysicalTopN<?>) physicalSink.child().child(0);
PhysicalTopN<?> newTopN = (PhysicalTopN<?>) oldTopN.accept(this, context);
if (newTopN == oldTopN) {
return physicalSink;
} else {
return physicalSink.withChildren(physicalSink.child().withChildren(newTopN));
}
}
return physicalSink;
}
Expand Down

0 comments on commit b99b9ef

Please sign in to comment.