[fix](Nereids) top-n with top project should hit top-n opt (#29971)
in PR #29312, we limit top-n opt only enable in simplest cases. in this PR, we let go of some restrictions.
This commit is contained in:
@ -52,6 +52,14 @@ public class TopNScanOpt extends PlanPostProcessor {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user