Skip to content

Commit

Permalink
[fix](Nereids) top-n with top project should hit top-n opt (apache#29971
Browse files Browse the repository at this point in the history
)

in PR apache#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 Jan 15, 2024
1 parent 0ffd6cf commit ce89a9f
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 ce89a9f

Please sign in to comment.