Skip to content

Commit 8b6b871

Browse files
authored
branch-4.0: [fix](test) fix regression sumRewrite #58232 (#58235)
### What problem does this PR solve? cherry-pick: #58232 ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
1 parent df2a963 commit 8b6b871

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

regression-test/data/nereids_rules_p0/sumRewrite.out

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
PhysicalResultSink
44
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
55
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(id as BIGINT) + 2)) AS `partial_sum((cast(id as BIGINT) + 2))`)]
6-
------PhysicalProject[(cast(id as BIGINT) + 2) AS `(cast(id as BIGINT) + 2)`]
6+
------PhysicalProject[sr.id]
77
--------PhysicalOlapScan[sr]
88

99
-- !sum_add_const_result --
@@ -13,7 +13,7 @@ PhysicalResultSink
1313
PhysicalResultSink
1414
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `result`)]
1515
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(id as BIGINT) + 2)) AS `partial_sum((cast(id as BIGINT) + 2))`)]
16-
------PhysicalProject[(cast(id as BIGINT) + 2) AS `(cast(id as BIGINT) + 2)`]
16+
------PhysicalProject[sr.id]
1717
--------PhysicalOlapScan[sr]
1818

1919
-- !sum_add_const_alias_result --
@@ -23,7 +23,7 @@ PhysicalResultSink
2323
PhysicalResultSink
2424
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
2525
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(id as BIGINT) + 2)) AS `partial_sum((cast(id as BIGINT) + 2))`)]
26-
------PhysicalProject[(cast(id as BIGINT) + 2) AS `(cast(id as BIGINT) + 2)`]
26+
------PhysicalProject[sr.id]
2727
--------filter(( not id IS NULL))
2828
----------PhysicalOlapScan[sr]
2929

@@ -34,7 +34,7 @@ PhysicalResultSink
3434
PhysicalResultSink
3535
--hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
3636
----hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(id as BIGINT) + 2)) AS `partial_sum((cast(id as BIGINT) + 2))`, sr.not_null_id)]
37-
------PhysicalProject[(cast(id as BIGINT) + 2) AS `(cast(id as BIGINT) + 2)`, sr.not_null_id]
37+
------PhysicalProject[sr.id, sr.not_null_id]
3838
--------PhysicalOlapScan[sr]
3939

4040
-- !sum_add_const_group_by_result --
@@ -49,7 +49,7 @@ PhysicalResultSink
4949
--filter((sum(id + 2) > 5))
5050
----hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
5151
------hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(id as BIGINT) + 2)) AS `partial_sum((cast(id as BIGINT) + 2))`, sr.not_null_id)]
52-
--------PhysicalProject[(cast(id as BIGINT) + 2) AS `(cast(id as BIGINT) + 2)`, sr.not_null_id]
52+
--------PhysicalProject[sr.id, sr.not_null_id]
5353
----------PhysicalOlapScan[sr]
5454

5555
-- !sum_add_const_having_result --
@@ -63,7 +63,7 @@ PhysicalResultSink
6363
PhysicalResultSink
6464
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
6565
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(id as BIGINT) - 2)) AS `partial_sum((cast(id as BIGINT) - 2))`)]
66-
------PhysicalProject[(cast(id as BIGINT) - 2) AS `(cast(id as BIGINT) - 2)`]
66+
------PhysicalProject[sr.id]
6767
--------PhysicalOlapScan[sr]
6868

6969
-- !sum_sub_const_result --
@@ -73,7 +73,7 @@ PhysicalResultSink
7373
PhysicalResultSink
7474
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `result`)]
7575
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(id as BIGINT) - 2)) AS `partial_sum((cast(id as BIGINT) - 2))`)]
76-
------PhysicalProject[(cast(id as BIGINT) - 2) AS `(cast(id as BIGINT) - 2)`]
76+
------PhysicalProject[sr.id]
7777
--------PhysicalOlapScan[sr]
7878

7979
-- !sum_sub_const_alias_result --
@@ -83,7 +83,7 @@ PhysicalResultSink
8383
PhysicalResultSink
8484
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
8585
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(id as BIGINT) - 2)) AS `partial_sum((cast(id as BIGINT) - 2))`)]
86-
------PhysicalProject[(cast(id as BIGINT) - 2) AS `(cast(id as BIGINT) - 2)`]
86+
------PhysicalProject[sr.id]
8787
--------filter(( not id IS NULL))
8888
----------PhysicalOlapScan[sr]
8989

@@ -94,7 +94,7 @@ PhysicalResultSink
9494
PhysicalResultSink
9595
--hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
9696
----hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(id as BIGINT) - 2)) AS `partial_sum((cast(id as BIGINT) - 2))`, sr.not_null_id)]
97-
------PhysicalProject[(cast(id as BIGINT) - 2) AS `(cast(id as BIGINT) - 2)`, sr.not_null_id]
97+
------PhysicalProject[sr.id, sr.not_null_id]
9898
--------PhysicalOlapScan[sr]
9999

100100
-- !sum_sub_const_group_by_result --
@@ -109,7 +109,7 @@ PhysicalResultSink
109109
--filter((sum(id - 2) > 0))
110110
----hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
111111
------hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(id as BIGINT) - 2)) AS `partial_sum((cast(id as BIGINT) - 2))`, sr.not_null_id)]
112-
--------PhysicalProject[(cast(id as BIGINT) - 2) AS `(cast(id as BIGINT) - 2)`, sr.not_null_id]
112+
--------PhysicalProject[sr.id, sr.not_null_id]
113113
----------PhysicalOlapScan[sr]
114114

115115
-- !sum_sub_const_having_result --
@@ -122,8 +122,7 @@ PhysicalResultSink
122122
-- !sum_add_const_empty_table_shape --
123123
PhysicalResultSink
124124
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
125-
----PhysicalProject[(cast(id as BIGINT) + 2) AS `(cast(id as BIGINT) + 2)`, sr.id]
126-
------PhysicalEmptyRelation
125+
----PhysicalEmptyRelation
127126

128127
-- !sum_add_const_empty_table_result --
129128
\N
@@ -137,8 +136,7 @@ PhysicalResultSink
137136
-- !sum_sub_const_empty_table_shape --
138137
PhysicalResultSink
139138
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
140-
----PhysicalProject[(cast(id as BIGINT) - 2) AS `(cast(id as BIGINT) - 2)`, sr.id]
141-
------PhysicalEmptyRelation
139+
----PhysicalEmptyRelation
142140

143141
-- !sum_sub_const_empty_table_result --
144142
\N
@@ -153,7 +151,7 @@ PhysicalResultSink
153151
PhysicalResultSink
154152
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) + 2.0)) AS `sum(f_id + 2)`)]
155153
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(f_id as DOUBLE) + 2.0)) AS `partial_sum((cast(f_id as DOUBLE) + 2.0))`)]
156-
------PhysicalProject[(cast(f_id as DOUBLE) + 2.0) AS `(cast(f_id as DOUBLE) + 2.0)`]
154+
------PhysicalProject[sr.f_id]
157155
--------PhysicalOlapScan[sr]
158156

159157
-- !float_sum_add_const_result --
@@ -163,7 +161,7 @@ PhysicalResultSink
163161
PhysicalResultSink
164162
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) + 2.0)) AS `result`)]
165163
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(f_id as DOUBLE) + 2.0)) AS `partial_sum((cast(f_id as DOUBLE) + 2.0))`)]
166-
------PhysicalProject[(cast(f_id as DOUBLE) + 2.0) AS `(cast(f_id as DOUBLE) + 2.0)`]
164+
------PhysicalProject[sr.f_id]
167165
--------PhysicalOlapScan[sr]
168166

169167
-- !float_sum_add_const_alias_result --
@@ -173,7 +171,7 @@ PhysicalResultSink
173171
PhysicalResultSink
174172
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) + 2.0)) AS `sum(f_id + 2)`)]
175173
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(f_id as DOUBLE) + 2.0)) AS `partial_sum((cast(f_id as DOUBLE) + 2.0))`)]
176-
------PhysicalProject[(cast(f_id as DOUBLE) + 2.0) AS `(cast(f_id as DOUBLE) + 2.0)`]
174+
------PhysicalProject[sr.f_id]
177175
--------filter(( not f_id IS NULL))
178176
----------PhysicalOlapScan[sr]
179177

@@ -184,13 +182,13 @@ PhysicalResultSink
184182
PhysicalResultSink
185183
--hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(f_id as DOUBLE) + 2.0)) AS `sum(f_id + 2)`)]
186184
----hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(f_id as DOUBLE) + 2.0)) AS `partial_sum((cast(f_id as DOUBLE) + 2.0))`, sr.not_null_id)]
187-
------PhysicalProject[(cast(f_id as DOUBLE) + 2.0) AS `(cast(f_id as DOUBLE) + 2.0)`, sr.not_null_id]
185+
------PhysicalProject[sr.f_id, sr.not_null_id]
188186
--------PhysicalOlapScan[sr]
189187

190188
-- !float_sum_add_const_group_by_result --
191-
10 24.0
189+
10 24
192190
6 7.300000071525574
193-
7 11.700000047683716
191+
7 11.70000004768372
194192
8 16.09999990463257
195193
9 20.5
196194

@@ -199,21 +197,21 @@ PhysicalResultSink
199197
--filter((sum(f_id + 2) > 5.0))
200198
----hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(f_id as DOUBLE) + 2.0)) AS `sum(f_id + 2)`)]
201199
------hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(f_id as DOUBLE) + 2.0)) AS `partial_sum((cast(f_id as DOUBLE) + 2.0))`, sr.not_null_id)]
202-
--------PhysicalProject[(cast(f_id as DOUBLE) + 2.0) AS `(cast(f_id as DOUBLE) + 2.0)`, sr.not_null_id]
200+
--------PhysicalProject[sr.f_id, sr.not_null_id]
203201
----------PhysicalOlapScan[sr]
204202

205203
-- !float_sum_add_const_having_result --
206-
10 24.0
204+
10 24
207205
6 7.300000071525574
208-
7 11.700000047683716
206+
7 11.70000004768372
209207
8 16.09999990463257
210208
9 20.5
211209

212210
-- !float_sum_sub_const_shape --
213211
PhysicalResultSink
214212
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) - 2.0)) AS `sum(f_id - 2)`)]
215213
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(f_id as DOUBLE) - 2.0)) AS `partial_sum((cast(f_id as DOUBLE) - 2.0))`)]
216-
------PhysicalProject[(cast(f_id as DOUBLE) - 2.0) AS `(cast(f_id as DOUBLE) - 2.0)`]
214+
------PhysicalProject[sr.f_id]
217215
--------PhysicalOlapScan[sr]
218216

219217
-- !float_sum_sub_const_result --
@@ -223,7 +221,7 @@ PhysicalResultSink
223221
PhysicalResultSink
224222
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) - 2.0)) AS `result`)]
225223
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(f_id as DOUBLE) - 2.0)) AS `partial_sum((cast(f_id as DOUBLE) - 2.0))`)]
226-
------PhysicalProject[(cast(f_id as DOUBLE) - 2.0) AS `(cast(f_id as DOUBLE) - 2.0)`]
224+
------PhysicalProject[sr.f_id]
227225
--------PhysicalOlapScan[sr]
228226

229227
-- !float_sum_sub_const_alias_result --
@@ -233,7 +231,7 @@ PhysicalResultSink
233231
PhysicalResultSink
234232
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) - 2.0)) AS `sum(f_id - 2)`)]
235233
----hashAgg[LOCAL, groupByExpr=(), outputExpr=(partial_sum((cast(f_id as DOUBLE) - 2.0)) AS `partial_sum((cast(f_id as DOUBLE) - 2.0))`)]
236-
------PhysicalProject[(cast(f_id as DOUBLE) - 2.0) AS `(cast(f_id as DOUBLE) - 2.0)`]
234+
------PhysicalProject[sr.f_id]
237235
--------filter(( not f_id IS NULL))
238236
----------PhysicalOlapScan[sr]
239237

@@ -244,11 +242,11 @@ PhysicalResultSink
244242
PhysicalResultSink
245243
--hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(f_id as DOUBLE) - 2.0)) AS `sum(f_id - 2)`)]
246244
----hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(f_id as DOUBLE) - 2.0)) AS `partial_sum((cast(f_id as DOUBLE) - 2.0))`, sr.not_null_id)]
247-
------PhysicalProject[(cast(f_id as DOUBLE) - 2.0) AS `(cast(f_id as DOUBLE) - 2.0)`, sr.not_null_id]
245+
------PhysicalProject[sr.f_id, sr.not_null_id]
248246
--------PhysicalOlapScan[sr]
249247

250248
-- !float_sum_sub_const_group_by_result --
251-
10 16.0
249+
10 16
252250
6 -0.6999999284744263
253251
7 3.700000047683716
254252
8 8.099999904632568
@@ -259,11 +257,11 @@ PhysicalResultSink
259257
--filter((sum(f_id - 2) > 0.0))
260258
----hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(f_id as DOUBLE) - 2.0)) AS `sum(f_id - 2)`)]
261259
------hashAgg[LOCAL, groupByExpr=(sr.not_null_id), outputExpr=(partial_sum((cast(f_id as DOUBLE) - 2.0)) AS `partial_sum((cast(f_id as DOUBLE) - 2.0))`, sr.not_null_id)]
262-
--------PhysicalProject[(cast(f_id as DOUBLE) - 2.0) AS `(cast(f_id as DOUBLE) - 2.0)`, sr.not_null_id]
260+
--------PhysicalProject[sr.f_id, sr.not_null_id]
263261
----------PhysicalOlapScan[sr]
264262

265263
-- !float_sum_sub_const_having_result --
266-
10 16.0
264+
10 16
267265
7 3.700000047683716
268266
8 8.099999904632568
269267
9 12.5

0 commit comments

Comments
 (0)