You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### 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 -->
Copy file name to clipboardExpand all lines: regression-test/data/nereids_rules_p0/sumRewrite.out
+28-30Lines changed: 28 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
PhysicalResultSink
4
4
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
5
5
----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]
7
7
--------PhysicalOlapScan[sr]
8
8
9
9
-- !sum_add_const_result --
@@ -13,7 +13,7 @@ PhysicalResultSink
13
13
PhysicalResultSink
14
14
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `result`)]
15
15
----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]
17
17
--------PhysicalOlapScan[sr]
18
18
19
19
-- !sum_add_const_alias_result --
@@ -23,7 +23,7 @@ PhysicalResultSink
23
23
PhysicalResultSink
24
24
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
25
25
----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]
27
27
--------filter(( not id IS NULL))
28
28
----------PhysicalOlapScan[sr]
29
29
@@ -34,7 +34,7 @@ PhysicalResultSink
34
34
PhysicalResultSink
35
35
--hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
36
36
----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]
38
38
--------PhysicalOlapScan[sr]
39
39
40
40
-- !sum_add_const_group_by_result --
@@ -49,7 +49,7 @@ PhysicalResultSink
49
49
--filter((sum(id + 2) > 5))
50
50
----hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) + 2)) AS `sum(id + 2)`)]
51
51
------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]
53
53
----------PhysicalOlapScan[sr]
54
54
55
55
-- !sum_add_const_having_result --
@@ -63,7 +63,7 @@ PhysicalResultSink
63
63
PhysicalResultSink
64
64
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
65
65
----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]
67
67
--------PhysicalOlapScan[sr]
68
68
69
69
-- !sum_sub_const_result --
@@ -73,7 +73,7 @@ PhysicalResultSink
73
73
PhysicalResultSink
74
74
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `result`)]
75
75
----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]
77
77
--------PhysicalOlapScan[sr]
78
78
79
79
-- !sum_sub_const_alias_result --
@@ -83,7 +83,7 @@ PhysicalResultSink
83
83
PhysicalResultSink
84
84
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
85
85
----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]
87
87
--------filter(( not id IS NULL))
88
88
----------PhysicalOlapScan[sr]
89
89
@@ -94,7 +94,7 @@ PhysicalResultSink
94
94
PhysicalResultSink
95
95
--hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
96
96
----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]
98
98
--------PhysicalOlapScan[sr]
99
99
100
100
-- !sum_sub_const_group_by_result --
@@ -109,7 +109,7 @@ PhysicalResultSink
109
109
--filter((sum(id - 2) > 0))
110
110
----hashAgg[GLOBAL, groupByExpr=(sr.not_null_id), outputExpr=(sr.not_null_id, sum((cast(id as BIGINT) - 2)) AS `sum(id - 2)`)]
111
111
------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]
113
113
----------PhysicalOlapScan[sr]
114
114
115
115
-- !sum_sub_const_having_result --
@@ -122,8 +122,7 @@ PhysicalResultSink
122
122
-- !sum_add_const_empty_table_shape --
123
123
PhysicalResultSink
124
124
--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
127
126
128
127
-- !sum_add_const_empty_table_result --
129
128
\N
@@ -137,8 +136,7 @@ PhysicalResultSink
137
136
-- !sum_sub_const_empty_table_shape --
138
137
PhysicalResultSink
139
138
--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
142
140
143
141
-- !sum_sub_const_empty_table_result --
144
142
\N
@@ -153,7 +151,7 @@ PhysicalResultSink
153
151
PhysicalResultSink
154
152
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) + 2.0)) AS `sum(f_id + 2)`)]
155
153
----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]
157
155
--------PhysicalOlapScan[sr]
158
156
159
157
-- !float_sum_add_const_result --
@@ -163,7 +161,7 @@ PhysicalResultSink
163
161
PhysicalResultSink
164
162
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) + 2.0)) AS `result`)]
165
163
----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]
167
165
--------PhysicalOlapScan[sr]
168
166
169
167
-- !float_sum_add_const_alias_result --
@@ -173,7 +171,7 @@ PhysicalResultSink
173
171
PhysicalResultSink
174
172
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) + 2.0)) AS `sum(f_id + 2)`)]
175
173
----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]
177
175
--------filter(( not f_id IS NULL))
178
176
----------PhysicalOlapScan[sr]
179
177
@@ -184,13 +182,13 @@ PhysicalResultSink
184
182
PhysicalResultSink
185
183
--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)`)]
186
184
----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]
188
186
--------PhysicalOlapScan[sr]
189
187
190
188
-- !float_sum_add_const_group_by_result --
191
-
10 24.0
189
+
10 24
192
190
6 7.300000071525574
193
-
7 11.700000047683716
191
+
7 11.70000004768372
194
192
8 16.09999990463257
195
193
9 20.5
196
194
@@ -199,21 +197,21 @@ PhysicalResultSink
199
197
--filter((sum(f_id + 2) > 5.0))
200
198
----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)`)]
201
199
------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]
203
201
----------PhysicalOlapScan[sr]
204
202
205
203
-- !float_sum_add_const_having_result --
206
-
10 24.0
204
+
10 24
207
205
6 7.300000071525574
208
-
7 11.700000047683716
206
+
7 11.70000004768372
209
207
8 16.09999990463257
210
208
9 20.5
211
209
212
210
-- !float_sum_sub_const_shape --
213
211
PhysicalResultSink
214
212
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) - 2.0)) AS `sum(f_id - 2)`)]
215
213
----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]
217
215
--------PhysicalOlapScan[sr]
218
216
219
217
-- !float_sum_sub_const_result --
@@ -223,7 +221,7 @@ PhysicalResultSink
223
221
PhysicalResultSink
224
222
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) - 2.0)) AS `result`)]
225
223
----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]
227
225
--------PhysicalOlapScan[sr]
228
226
229
227
-- !float_sum_sub_const_alias_result --
@@ -233,7 +231,7 @@ PhysicalResultSink
233
231
PhysicalResultSink
234
232
--hashAgg[GLOBAL, groupByExpr=(), outputExpr=(sum((cast(f_id as DOUBLE) - 2.0)) AS `sum(f_id - 2)`)]
235
233
----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]
237
235
--------filter(( not f_id IS NULL))
238
236
----------PhysicalOlapScan[sr]
239
237
@@ -244,11 +242,11 @@ PhysicalResultSink
244
242
PhysicalResultSink
245
243
--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)`)]
246
244
----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]
248
246
--------PhysicalOlapScan[sr]
249
247
250
248
-- !float_sum_sub_const_group_by_result --
251
-
10 16.0
249
+
10 16
252
250
6 -0.6999999284744263
253
251
7 3.700000047683716
254
252
8 8.099999904632568
@@ -259,11 +257,11 @@ PhysicalResultSink
259
257
--filter((sum(f_id - 2) > 0.0))
260
258
----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)`)]
261
259
------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]
0 commit comments