This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 2120115e84e [fix](nereids) fix ptopN push down under multi winexprs
with partial forbidden type (#44655)
2120115e84e is described below
commit 2120115e84ecd66b4fb17770b94da9340b0016a4
Author: xzj7019 <[email protected]>
AuthorDate: Thu Nov 28 16:04:38 2024 +0800
[fix](nereids) fix ptopN push down under multi winexprs with partial
forbidden type (#44655)
pick from https://github.com/apache/doris/pull/44617
---
.../nereids/trees/plans/logical/LogicalWindow.java | 10 +++---
.../data/nereids_syntax_p0/window_function.out | 6 ++++
.../push_down_multi_filter_through_window.groovy | 20 +++++++++++
.../nereids_syntax_p0/window_function.groovy | 39 ++++++++++++++++++++++
4 files changed, 70 insertions(+), 5 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java
index fceb36e677f..68ccea774f1 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java
@@ -218,7 +218,7 @@ public class LogicalWindow<CHILD_TYPE extends Plan> extends
LogicalUnary<CHILD_T
for (NamedExpression windowExpr : windowExpressions) {
if (windowExpr == null || windowExpr.children().size() != 1
|| !(windowExpr.child(0) instanceof WindowExpression)) {
- continue;
+ return null;
}
WindowExpression windowFunc = (WindowExpression)
windowExpr.child(0);
@@ -226,12 +226,12 @@ public class LogicalWindow<CHILD_TYPE extends Plan>
extends LogicalUnary<CHILD_T
if (!(windowFunc.getFunction() instanceof RowNumber
|| windowFunc.getFunction() instanceof Rank
|| windowFunc.getFunction() instanceof DenseRank)) {
- continue;
+ return null;
}
// Check the partition key and order key.
if (windowFunc.getPartitionKeys().isEmpty() &&
windowFunc.getOrderKeys().isEmpty()) {
- continue;
+ return null;
}
// Check the window type and window frame.
@@ -240,10 +240,10 @@ public class LogicalWindow<CHILD_TYPE extends Plan>
extends LogicalUnary<CHILD_T
WindowFrame frame = windowFrame.get();
if (!(frame.getLeftBoundary().getFrameBoundType() ==
WindowFrame.FrameBoundType.UNBOUNDED_PRECEDING
&& frame.getRightBoundary().getFrameBoundType() ==
WindowFrame.FrameBoundType.CURRENT_ROW)) {
- continue;
+ return null;
}
} else {
- continue;
+ return null;
}
// Check filter conditions.
diff --git a/regression-test/data/nereids_syntax_p0/window_function.out
b/regression-test/data/nereids_syntax_p0/window_function.out
index 4ec92fc61ad..38eba68274e 100644
--- a/regression-test/data/nereids_syntax_p0/window_function.out
+++ b/regression-test/data/nereids_syntax_p0/window_function.out
@@ -561,3 +561,9 @@
\N
\N
+-- !multi_winf1 --
+1 c
+
+-- !multi_winf2 --
+1 35
+
diff --git
a/regression-test/suites/nereids_rules_p0/push_down_filter_through_window/push_down_multi_filter_through_window.groovy
b/regression-test/suites/nereids_rules_p0/push_down_filter_through_window/push_down_multi_filter_through_window.groovy
index d808d30f8eb..015a6e7fae7 100644
---
a/regression-test/suites/nereids_rules_p0/push_down_filter_through_window/push_down_multi_filter_through_window.groovy
+++
b/regression-test/suites/nereids_rules_p0/push_down_filter_through_window/push_down_multi_filter_through_window.groovy
@@ -157,4 +157,24 @@ suite("push_down_multi_filter_through_window") {
sql ("select * from (select row_number() over(partition by c1, c2
order by c3) as rn, rank() over(partition by c1 order by c3) as rk from
push_down_multi_predicate_through_window_t) t where rn <= 1 or rk <= 1;")
notContains "VPartitionTopN"
}
+
+ explain {
+ sql ("select * from (select row_number() over(partition by c1, c2
order by c3) as rn, sum(c2) over(order by c2 range between unbounded preceding
and unbounded following) as sw from push_down_multi_predicate_through_window_t)
t where rn <= 1 and sw <= 1;")
+ notContains "VPartitionTopN"
+ }
+
+ explain {
+ sql ("select * from (select sum(c2) over(order by c2 range between
unbounded preceding and unbounded following) as sw, row_number() over(partition
by c1, c2 order by c3) as rn from push_down_multi_predicate_through_window_t) t
where rn <= 1 and sw <= 1;")
+ notContains "VPartitionTopN"
+ }
+
+ explain {
+ sql ("select * from (select row_number() over(partition by c1, c2
order by c3 rows between unbounded preceding and current row) as rn, sum(c2)
over(order by c2) as sw from push_down_multi_predicate_through_window_t) t
where rn <= 1 and sw <= 1;")
+ notContains "VPartitionTopN"
+ }
+
+ explain {
+ sql ("select * from (select sum(c2) over(order by c2) as sw,
row_number() over(partition by c1, c2 order by c3 rows between unbounded
preceding and current row) as rn from
push_down_multi_predicate_through_window_t) t where rn <= 1 and sw <= 1;")
+ notContains "VPartitionTopN"
+ }
}
diff --git a/regression-test/suites/nereids_syntax_p0/window_function.groovy
b/regression-test/suites/nereids_syntax_p0/window_function.groovy
index 9a427d10198..31cb425fcf7 100644
--- a/regression-test/suites/nereids_syntax_p0/window_function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/window_function.groovy
@@ -240,4 +240,43 @@ suite("window_function") {
"""
qt_sql """ select LAST_VALUE(col_tinyint_undef_signed_not_null) over
(partition by col_double_undef_signed_not_null, col_int_undef_signed,
(col_float_undef_signed_not_null - col_int_undef_signed),
round_bankers(col_int_undef_signed) order by pk rows between unbounded
preceding and 4 preceding) AS col_alias56089 from
table_200_undef_partitions2_keys3_properties4_distributed_by53 order by
col_alias56089; """
+
+ order_qt_multi_winf1 """
+ select *
+ from (
+ select
+ row_number() over(partition by c1 order by c2) rn,
+ lead(c2, 2, '') over(partition by c1 order by c2)
+ from (
+ select 1 as c1, 'a' as c2
+ union all
+ select 1 as c1, 'b' as c2
+ union all
+ select 1 as c1, 'c' as c2
+ union all
+ select 1 as c1, 'd' as c2
+ union all
+ select 1 as c1, 'e' as c2
+ )t
+ )a where rn=1
+ """
+ order_qt_multi_winf2 """
+ select *
+ from (
+ select
+ row_number() over(partition by c1 order by c2) rn,
+ sum(c2) over(order by c2 range between unbounded preceding and
unbounded following)
+ from (
+ select 1 as c1, 5 as c2
+ union all
+ select 1 as c1, 6 as c2
+ union all
+ select 1 as c1, 7 as c2
+ union all
+ select 1 as c1, 8 as c2
+ union all
+ select 1 as c1, 9 as c2
+ )t
+ )a where rn=1
+ """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]