This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new a05505a83f2 [fix](Nereids) top-n with top project should hit top-n opt
(#29971) (#30521)
a05505a83f2 is described below
commit a05505a83f29cbd5aaa99ab28fdc1b1547131dc2
Author: morrySnow <[email protected]>
AuthorDate: Tue Jan 30 10:12:41 2024 +0800
[fix](Nereids) top-n with top project should hit top-n opt (#29971) (#30521)
in PR #29312, we limit top-n opt only enable in simplest cases.
in this PR, we let go of some restrictions.
pick from master #29971
commit id ce89a9f07c561317fefe8023047269ea3b264038
---
.../java/org/apache/doris/nereids/processor/post/TopNScanOpt.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopNScanOpt.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopNScanOpt.java
index 31a2a7aff56..1fb078fa643 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopNScanOpt.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopNScanOpt.java
@@ -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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]