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 81fa78e3b0c branch-2.1: [fix](nereids) fix window expression alias
reuse expr id #55286 (#55493)
81fa78e3b0c is described below
commit 81fa78e3b0cffef58efe838785b7eb40c3cc1a73
Author: yujun <[email protected]>
AuthorDate: Sat Aug 30 15:39:52 2025 +0800
branch-2.1: [fix](nereids) fix window expression alias reuse expr id #55286
(#55493)
cherry pick from #55286
---
.../doris/nereids/rules/rewrite/NormalizeToSlot.java | 8 ++++++++
.../ExtractAndNormalizeWindowExpressionTest.java | 7 +++----
.../push_down_filter_through_window.out | Bin 907 -> 911 bytes
.../nereids_syntax_p0/push_filter_through_ptopn.out | Bin 1408 -> 1416 bytes
.../nonConcurrent/hint_tpcds_p0/shape/query44.out | Bin 4899 -> 4907 bytes
.../nonConcurrent/hint_tpcds_p0/shape/query49.out | Bin 8593 -> 8629 bytes
.../nonConcurrent/hint_tpcds_p0/shape/query51.out | Bin 2912 -> 2916 bytes
.../nonConcurrent/hint_tpcds_p0/shape/query67.out | Bin 2289 -> 2293 bytes
.../b/query44_bs_downgrade_shape.out | Bin 4820 -> 4828 bytes
.../tpcds_shape_sf1000_p0/shape/query44.out | Bin 4820 -> 4828 bytes
.../tpcds_shape_sf1000_p0/shape/query49.out | Bin 8593 -> 8629 bytes
.../tpcds_shape_sf1000_p0/shape/query51.out | Bin 2793 -> 2797 bytes
.../tpcds_shape_sf1000_p0/shape/query67.out | Bin 2178 -> 2182 bytes
.../tpcds_shape_sf100_p0/n/query44_no_stats_shape.out | Bin 5018 -> 5026 bytes
.../tpcds_shape_sf100_p0/n/query49_no_stats_shape.out | Bin 8818 -> 8854 bytes
.../tpcds_shape_sf100_p0/n/query51_no_stats_shape.out | Bin 2793 -> 2797 bytes
.../tpcds_shape_sf100_p0/n/query67_no_stats_shape.out | Bin 2114 -> 2118 bytes
.../ns/query44_noStatsRfPrune.out | Bin 5018 -> 5026 bytes
.../ns/query49_noStatsRfPrune.out | Bin 8818 -> 8854 bytes
.../ns/query51_noStatsRfPrune.out | Bin 2793 -> 2797 bytes
.../ns/query67_noStatsRfPrune.out | Bin 2028 -> 2032 bytes
.../tpcds_shape_sf100_p0/rf_prune/query44.out | Bin 4826 -> 4834 bytes
.../tpcds_shape_sf100_p0/rf_prune/query49.out | Bin 8593 -> 8629 bytes
.../tpcds_shape_sf100_p0/rf_prune/query51.out | Bin 2793 -> 2797 bytes
.../tpcds_shape_sf100_p0/rf_prune/query67.out | Bin 2020 -> 2024 bytes
.../tpcds_shape_sf100_p0/shape/query44.out | Bin 4826 -> 4834 bytes
.../tpcds_shape_sf100_p0/shape/query49.out | Bin 8593 -> 8629 bytes
.../tpcds_shape_sf100_p0/shape/query51.out | Bin 2793 -> 2797 bytes
.../tpcds_shape_sf100_p0/shape/query67.out | Bin 2106 -> 2110 bytes
.../data/variant_p0/test_sub_path_pruning.out | Bin 5855 -> 5946 bytes
.../suites/variant_p0/test_sub_path_pruning.groovy | 8 +++++++-
31 files changed, 18 insertions(+), 5 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
index 0e1fba1fc44..85367107a2c 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
@@ -125,6 +125,14 @@ public interface NormalizeToSlot {
NormalizeToSlotTriplet normalizeToSlotTriplet =
normalizeToSlotMap.get(child);
return normalizeToSlotTriplet == null ? child :
normalizeToSlotTriplet.remainExpr;
});
+ if (rewriteExpr instanceof Alias) {
+ Alias alias = (Alias) rewriteExpr;
+ if (alias.child() instanceof SlotReference
+ && alias.getExprId().equals(((SlotReference)
alias.child()).getExprId())) {
+ // alias k1#1 as k1#1 --> k1#1
+ rewriteExpr = alias.child();
+ }
+ }
result.add((E) rewriteExpr);
}
return result.build();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpressionTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpressionTest.java
index 476131e6b06..a3527f5d501 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpressionTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpressionTest.java
@@ -90,7 +90,7 @@ public class ExtractAndNormalizeWindowExpressionTest
implements MemoPatternMatch
).when(project -> {
List<NamedExpression> projects =
project.getProjects();
return projects.get(0).equals(id)
- && projects.get(1) instanceof Alias;
+ && projects.get(1) instanceof SlotReference &&
projects.get(1).equals(windowAlias.toSlot());
})
);
}
@@ -147,7 +147,7 @@ public class ExtractAndNormalizeWindowExpressionTest
implements MemoPatternMatch
).when(project -> {
List<NamedExpression> projects =
project.getProjects();
return projects.get(0) instanceof SlotReference
- && projects.get(1) instanceof Alias;
+ && projects.get(1) instanceof SlotReference &&
projects.get(1).equals(windowAlias.toSlot());
})
);
}
@@ -226,8 +226,7 @@ public class ExtractAndNormalizeWindowExpressionTest
implements MemoPatternMatch
List<NamedExpression> projects =
project.getProjects();
return projects.get(0).equals(gender)
&& projects.get(1) instanceof SlotReference
- && projects.get(2) instanceof Alias
- && projects.get(2).child(0) instanceof
SlotReference;
+ && projects.get(2) instanceof SlotReference &&
projects.get(2).equals(windowAlias.toSlot());
})
);
}
diff --git
a/regression-test/data/nereids_rules_p0/push_down_filter/push_down_filter_through_window.out
b/regression-test/data/nereids_rules_p0/push_down_filter/push_down_filter_through_window.out
index 9ecb96e1fc0..6efd09e5d1d 100644
Binary files
a/regression-test/data/nereids_rules_p0/push_down_filter/push_down_filter_through_window.out
and
b/regression-test/data/nereids_rules_p0/push_down_filter/push_down_filter_through_window.out
differ
diff --git
a/regression-test/data/nereids_syntax_p0/push_filter_through_ptopn.out
b/regression-test/data/nereids_syntax_p0/push_filter_through_ptopn.out
index dd23fd8ea50..49e5abb8c5f 100644
Binary files
a/regression-test/data/nereids_syntax_p0/push_filter_through_ptopn.out and
b/regression-test/data/nereids_syntax_p0/push_filter_through_ptopn.out differ
diff --git a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query44.out
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query44.out
index 46c087a5787..28ec1ba2f6f 100644
Binary files
a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query44.out and
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query44.out differ
diff --git a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query49.out
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query49.out
index 76b88bd85d5..7bd9127746c 100644
Binary files
a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query49.out and
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query49.out differ
diff --git a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query51.out
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query51.out
index a118ffcd777..976b1664aec 100644
Binary files
a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query51.out and
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query51.out differ
diff --git a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query67.out
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query67.out
index 50487a4a3c1..417a640b8ea 100644
Binary files
a/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query67.out and
b/regression-test/data/nonConcurrent/hint_tpcds_p0/shape/query67.out differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/b/query44_bs_downgrade_shape.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/b/query44_bs_downgrade_shape.out
index 4f1a1be1c25..55f915657f7 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/b/query44_bs_downgrade_shape.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/b/query44_bs_downgrade_shape.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query44.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query44.out
index 4f1a1be1c25..55f915657f7 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query44.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query44.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query49.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query49.out
index 76b88bd85d5..7bd9127746c 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query49.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query49.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query51.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query51.out
index 715ffb8960a..e91d43590ca 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query51.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query51.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query67.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query67.out
index 8704ff806ed..f0660a82c91 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query67.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf1000_p0/shape/query67.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query44_no_stats_shape.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query44_no_stats_shape.out
index 0c8451a1e79..6273f16b2c5 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query44_no_stats_shape.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query44_no_stats_shape.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query49_no_stats_shape.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query49_no_stats_shape.out
index 4edce3d0ff6..8f170d9a28f 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query49_no_stats_shape.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query49_no_stats_shape.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query51_no_stats_shape.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query51_no_stats_shape.out
index 8158a7de181..547325462c2 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query51_no_stats_shape.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query51_no_stats_shape.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query67_no_stats_shape.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query67_no_stats_shape.out
index 900fe97ff05..6604a6cd577 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query67_no_stats_shape.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/n/query67_no_stats_shape.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query44_noStatsRfPrune.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query44_noStatsRfPrune.out
index 0c8451a1e79..6273f16b2c5 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query44_noStatsRfPrune.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query44_noStatsRfPrune.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query49_noStatsRfPrune.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query49_noStatsRfPrune.out
index 4edce3d0ff6..8f170d9a28f 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query49_noStatsRfPrune.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query49_noStatsRfPrune.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query51_noStatsRfPrune.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query51_noStatsRfPrune.out
index 8158a7de181..547325462c2 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query51_noStatsRfPrune.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query51_noStatsRfPrune.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query67_noStatsRfPrune.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query67_noStatsRfPrune.out
index 246d2337283..9d9a5550f3a 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query67_noStatsRfPrune.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/ns/query67_noStatsRfPrune.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query44.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query44.out
index 7d9cf4de279..923ccad80c7 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query44.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query44.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query49.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query49.out
index a52f8f454fd..e14d114ce17 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query49.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query49.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query51.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query51.out
index 8158a7de181..547325462c2 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query51.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query51.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query67.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query67.out
index bd3f6458a3c..c8915eba210 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query67.out
and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/rf_prune/query67.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query44.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query44.out
index 7d9cf4de279..923ccad80c7 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query44.out and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query44.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query49.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query49.out
index a52f8f454fd..e14d114ce17 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query49.out and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query49.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query51.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query51.out
index 8158a7de181..547325462c2 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query51.out and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query51.out
differ
diff --git
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query67.out
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query67.out
index d069db662b3..10bfc19cec4 100644
Binary files
a/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query67.out and
b/regression-test/data/nonConcurrent/tpcds_shape_sf100_p0/shape/query67.out
differ
diff --git a/regression-test/data/variant_p0/test_sub_path_pruning.out
b/regression-test/data/variant_p0/test_sub_path_pruning.out
index 16328739167..13cd70dba08 100644
Binary files a/regression-test/data/variant_p0/test_sub_path_pruning.out and
b/regression-test/data/variant_p0/test_sub_path_pruning.out differ
diff --git a/regression-test/suites/variant_p0/test_sub_path_pruning.groovy
b/regression-test/suites/variant_p0/test_sub_path_pruning.groovy
index bd819934910..76d0deb4e2a 100644
--- a/regression-test/suites/variant_p0/test_sub_path_pruning.groovy
+++ b/regression-test/suites/variant_p0/test_sub_path_pruning.groovy
@@ -216,4 +216,10 @@ suite("variant_sub_path_pruning", "variant_type"){
order_qt_sql """select c1['a'] as c2, c1['b'] as c3 from (select 1 as id,
cast('{"a":1, "b":2}' as variant) as c1 order by id limit 100) tmp;"""
order_qt_sql """select c1['a'] from (select 1 as id, cast('{"b":{"a":1}}'
as variant)["b"] as c1 order by id limit 100) tmp;"""
order_qt_sql """select c1['a'] as c2, c1['b'] as c3 from (select 1 as id,
cast('{"b":{"a":1, "b":2}}' as variant)["b"] as c1 order by id limit 100)
tmp;"""
-}
\ No newline at end of file
+
+ order_qt_sql_no_dead_loop """
+ select
+ FIRST_VALUE(dt['a']) over (PARTITION by id) A12708
+ FROM pruning_test
+ """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]