You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2024/04/16 12:03:28 UTC
(doris) 05/39: [fix](nereids) ExtractAndNormalizeWindowExpression should only normalize alias in output (#33527)
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
commit bd9d1e7610c50e088ce9df4187ed8336e8860e5b
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Mon Apr 15 11:39:30 2024 +0800
[fix](nereids) ExtractAndNormalizeWindowExpression should only normalize alias in output (#33527)
---
.../nereids/rules/rewrite/ExtractAndNormalizeWindowExpression.java | 5 ++++-
.../suites/nereids_p0/aggregate/agg_window_project.groovy | 2 ++
2 files changed, 6 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 5ec0f0cd698..6f067545cee 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
@@ -123,8 +123,11 @@ public class ExtractAndNormalizeWindowExpression extends OneRewriteRuleFactory i
.collect(Collectors.toMap(expr -> ((Alias) expr).child(), expr -> ((Alias) expr).toSlot(),
(oldExpr, newExpr) -> oldExpr));
+ // customNormalizeMap is only for alias, so we just normalize alias in outputs too
List<NamedExpression> normalizedOutputs = context.normalizeToUseSlotRef(outputs,
- (ctx, expr) -> customNormalizeMap.getOrDefault(expr, null));
+ (ctx, expr) -> expr instanceof Alias ? customNormalizeMap.getOrDefault(expr, null) : null);
+ // replace child exprs in normalizedOutputs by customNormalizeMap
+ normalizedOutputs = ExpressionUtils.replaceNamedExpressions(normalizedOutputs, customNormalizeMap);
Set<WindowExpression> normalizedWindows =
ExpressionUtils.collect(normalizedOutputs, WindowExpression.class::isInstance);
diff --git a/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy b/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy
index 48d342b4b02..ace63dce3b4 100644
--- a/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy
@@ -103,5 +103,7 @@ suite("agg_window_project") {
contains "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"
}
+ sql """select a, a aa, row_number() over (partition by b) from test_window_table2;"""
+
sql "DROP TABLE IF EXISTS test_window_table2;"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org