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 f966088fd08 branch-2.1: [fix](nereids) fix
ExtractAndNormalizeWindowExpression bug #45553 (#45635)
f966088fd08 is described below
commit f966088fd086d74a58fbe09f94ba241812f8cbf2
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Dec 19 19:13:03 2024 +0800
branch-2.1: [fix](nereids) fix ExtractAndNormalizeWindowExpression bug
#45553 (#45635)
Cherry-picked from #45553
Co-authored-by: feiniaofeiafei <[email protected]>
---
.../ExtractAndNormalizeWindowExpression.java | 3 +-
.../normalize_window_nullable_agg_test.out | 4 ++
.../normalize_window_nullable_agg_test.groovy | 57 ++++++++++++++++++++++
3 files changed, 63 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpression.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpression.java
index 2cfe4523003..a74ebe4b76b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpression.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpression.java
@@ -27,6 +27,7 @@ import
org.apache.doris.nereids.trees.expressions.OrderExpression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.WindowExpression;
import
org.apache.doris.nereids.trees.expressions.functions.agg.NullableAggregateFunction;
+import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import org.apache.doris.nereids.trees.plans.logical.LogicalWindow;
@@ -117,7 +118,7 @@ public class ExtractAndNormalizeWindowExpression extends
OneRewriteRuleFactory i
// we need replace alias's child expr with corresponding alias's slot
in output
// so create a customNormalizeMap alias's child -> alias.toSlot to do
it
Map<Expression, Slot> customNormalizeMap = toBePushedDown.stream()
- .filter(expr -> expr instanceof Alias)
+ .filter(expr -> expr instanceof Alias && !(expr.child(0)
instanceof Literal))
.collect(Collectors.toMap(expr -> ((Alias) expr).child(), expr
-> ((Alias) expr).toSlot(),
(oldExpr, newExpr) -> oldExpr));
diff --git
a/regression-test/data/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.out
b/regression-test/data/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.out
index b9b811452d6..332c4fa2575 100644
---
a/regression-test/data/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.out
+++
b/regression-test/data/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.out
@@ -291,3 +291,7 @@ false
false
false
+-- !fold_window --
+0 false 0 be
+9999-12-31 23:59:59 false 9999-12-31 23:59:59 b
+
diff --git
a/regression-test/suites/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.groovy
b/regression-test/suites/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.groovy
index 7087797e4e4..3ae299517a6 100644
---
a/regression-test/suites/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.groovy
+++
b/regression-test/suites/nereids_rules_p0/normalize_window/normalize_window_nullable_agg_test.groovy
@@ -76,4 +76,61 @@ suite("normalize_window_nullable_agg") {
sql "select group_concat(xwho order by xwhat) over(partition by xwhen)
from windowfunnel_test_normalize_window;"
exception "order by is not supported"
}
+
+ sql "set enable_fold_constant_by_be = 1;"
+ sql "drop table if exists fold_window1"
+ sql """create table fold_window1 (
+ pk int,
+ col_char_255__undef_signed char(255) null ,
+ col_char_100__undef_signed char(100) null ,
+ col_varchar_255__undef_signed varchar(255) null ,
+ col_char_255__undef_signed_not_null char(255) not null ,
+ col_char_100__undef_signed_not_null char(100) not null ,
+ col_varchar_255__undef_signed_not_null varchar(255) not null ,
+ col_varchar_1000__undef_signed varchar(1000) null ,
+ col_varchar_1000__undef_signed_not_null varchar(1000) not null ,
+ col_varchar_1001__undef_signed varchar(1001) null ,
+ col_varchar_1001__undef_signed_not_null varchar(1001) not null ,
+ col_string_undef_signed string null ,
+ col_string_undef_signed_not_null string not null
+ ) engine=olap
+ DUPLICATE KEY(pk, col_char_255__undef_signed, col_char_100__undef_signed,
col_varchar_255__undef_signed)
+ distributed by hash(pk) buckets 10
+ properties("bloom_filter_columns" = "col_char_255__undef_signed,
col_char_100__undef_signed, col_varchar_255__undef_signed ", "replication_num"
= "1");"""
+ sql """insert into
fold_window1(pk,col_char_255__undef_signed,col_char_255__undef_signed_not_null,col_char_100__undef_signed
+
,col_char_100__undef_signed_not_null,col_varchar_255__undef_signed,col_varchar_255__undef_signed_not_null,col_varchar_1000__undef_signed,col_varchar_1000__undef_signed_not_null
+
,col_varchar_1001__undef_signed,col_varchar_1001__undef_signed_not_null,col_string_undef_signed,col_string_undef_signed_not_null)
+ values (0,'like','9999-12-31 23:59:59','9999-12-31
23:59:59','c','20240803','2024-08-03
13:08:30','300.343','2024-07-01','that''s','9999-12-31 23:59:59','s','b'),
+ (1,'be','g','f','not','20240803','20240803','2024-08-03
13:08:30','g','20240803','0','2024-07-01','be')"""
+
+ sql "drop table if exists fold_window2"
+ sql """create table fold_window2 (
+ pk int,
+ col_char_255__undef_signed char(255) null ,
+ col_char_255__undef_signed_not_null char(255) not null ,
+ col_char_100__undef_signed char(100) null ,
+ col_char_100__undef_signed_not_null char(100) not null ,
+ col_varchar_255__undef_signed varchar(255) null ,
+ col_varchar_255__undef_signed_not_null varchar(255) not null ,
+ col_varchar_1000__undef_signed varchar(1000) null ,
+ col_varchar_1000__undef_signed_not_null varchar(1000) not null ,
+ col_varchar_1001__undef_signed varchar(1001) null ,
+ col_varchar_1001__undef_signed_not_null varchar(1001) not null ,
+ col_string_undef_signed string null ,
+ col_string_undef_signed_not_null string not null
+ ) engine=olap
+ DUPLICATE KEY(pk)
+ distributed by hash(pk) buckets 10
+ properties ("bloom_filter_columns" = "col_char_255__undef_signed,
col_char_100__undef_signed, col_varchar_255__undef_signed ", "replication_num"
= "1");"""
+ sql """insert into
fold_window2(pk,col_char_255__undef_signed,col_char_255__undef_signed_not_null,col_char_100__undef_signed
+
,col_char_100__undef_signed_not_null,col_varchar_255__undef_signed,col_varchar_255__undef_signed_not_null,col_varchar_1000__undef_signed
+
,col_varchar_1000__undef_signed_not_null,col_varchar_1001__undef_signed,col_varchar_1001__undef_signed_not_null,col_string_undef_signed,col_string_undef_signed_not_null)
+ values (0,'some','2024-07-01','9999-12-31 23:59:59','9999-12-31
23:59:59','9999-12-31
23:59:59','300.343','2024-07-01','1','1','2024-07-01','2024-08-03
13:08:30','2024-08-03 13:08:30');"""
+
+ qt_fold_window """
+ select initcap(col_varchar_1001__undef_signed_not_null) col_alias97650 ,
starts_with('ourBZbRijD', "e") AS col_alias97651 ,
+ col_varchar_1001__undef_signed_not_null AS col_alias97652 ,
LAST_VALUE(col_string_undef_signed_not_null , false) over ( order by pk )
+ AS col_alias97653 from fold_window1 where 'DCOFMrybqf' <> (select min (
col_char_255__undef_signed )
+ from fold_window2) ORDER BY
col_alias97650,col_alias97651,col_alias97652,col_alias97653 ;
+ """
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]