Skip to content

Commit

Permalink
[opt](nereids) support partitionTopn for multi window exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjian.xzj authored and zhongjian.xzj committed Aug 5, 2024
1 parent 54db42c commit 95c8ad6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Rule build() {
return filter;
}

Pair<WindowExpression, Long> windowFuncPair = window.checkAndGetValidWindowFunc(filter, Long.MAX_VALUE);
Pair<WindowExpression, Long> windowFuncPair = window.getPushDownWindowFuncAndLimit(filter, Long.MAX_VALUE);
if (windowFuncPair == null) {
return filter;
} else if (windowFuncPair.second == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public List<Rule> buildRules() {
return limit;
}
Pair<WindowExpression, Long> windowFuncLongPair = window
.checkAndGetValidWindowFunc(null, partitionLimit);
.getPushDownWindowFuncAndLimit(null, partitionLimit);
if (windowFuncLongPair == null) {
return limit;
}
Expand All @@ -96,7 +96,7 @@ public List<Rule> buildRules() {
return limit;
}
Pair<WindowExpression, Long> windowFuncLongPair = window
.checkAndGetValidWindowFunc(null, partitionLimit);
.getPushDownWindowFuncAndLimit(null, partitionLimit);
if (windowFuncLongPair == null) {
return limit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<Rule> buildRules() {
}
long partitionLimit = topn.getLimit() + topn.getOffset();
Pair<WindowExpression, Long> windowFuncLongPair = window
.checkAndGetValidWindowFunc(null, partitionLimit);
.getPushDownWindowFuncAndLimit(null, partitionLimit);
if (windowFuncLongPair == null) {
return topn;
}
Expand All @@ -78,7 +78,7 @@ public List<Rule> buildRules() {
}
long partitionLimit = topn.getLimit() + topn.getOffset();
Pair<WindowExpression, Long> windowFuncLongPair = window
.checkAndGetValidWindowFunc(null, partitionLimit);
.getPushDownWindowFuncAndLimit(null, partitionLimit);
if (windowFuncLongPair == null) {
return topn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public int hashCode() {
}

/**
* Get push down window function candidate and corresponding partition limit.
*
* @param filter
* For partition topN filter cases, it means the topN filter;
Expand All @@ -194,7 +195,7 @@ public int hashCode() {
* else return the chosen window function and the chosen partition limit.
* A special limit -1 means the case can be optimized as empty relation.
*/
public Pair<WindowExpression, Long> checkAndGetValidWindowFunc(LogicalFilter<?> filter, long partitionLimit) {
public Pair<WindowExpression, Long> getPushDownWindowFuncAndLimit(LogicalFilter<?> filter, long partitionLimit) {
if (!ConnectContext.get().getSessionVariable().isEnablePartitionTopN()) {
return null;
}
Expand Down

0 comments on commit 95c8ad6

Please sign in to comment.