@@ -12,6 +12,7 @@ use polars_plan::prelude::GroupbyOptions;
12
12
use polars_utils:: arena:: { Arena , Node } ;
13
13
use polars_utils:: itertools:: Itertools ;
14
14
use polars_utils:: pl_str:: PlSmallStr ;
15
+ use recursive:: recursive;
15
16
use slotmap:: SlotMap ;
16
17
17
18
use super :: lower_expr:: lower_exprs;
@@ -71,6 +72,7 @@ fn build_group_by_fallback(
71
72
///
72
73
/// Such an expression is defined as the elementwise combination of scalar
73
74
/// aggregations of elementwise combinations of the input columns / scalar literals.
75
+ #[ recursive]
74
76
fn try_lower_elementwise_scalar_agg_expr (
75
77
expr : Node ,
76
78
inside_agg : bool ,
@@ -178,7 +180,10 @@ fn try_lower_elementwise_scalar_agg_expr(
178
180
} ,
179
181
180
182
AExpr :: Agg ( agg) => {
181
- let orig_agg = agg. clone ( ) ;
183
+ // Nested aggregates not supported.
184
+ if inside_agg {
185
+ return None ;
186
+ }
182
187
match agg {
183
188
IRAggExpr :: Min { input, .. }
184
189
| IRAggExpr :: Max { input, .. }
@@ -188,10 +193,7 @@ fn try_lower_elementwise_scalar_agg_expr(
188
193
| IRAggExpr :: Sum ( input)
189
194
| IRAggExpr :: Var ( input, ..)
190
195
| IRAggExpr :: Std ( input, ..) => {
191
- // Nested aggregates not supported.
192
- if inside_agg {
193
- return None ;
194
- }
196
+ let orig_agg = agg. clone ( ) ;
195
197
// Lower and replace input.
196
198
let trans_input = lower_rec ! ( * input, true ) ?;
197
199
let mut trans_agg = orig_agg;
@@ -311,7 +313,8 @@ fn try_build_streaming_group_by(
311
313
& mut trans_agg_exprs,
312
314
& trans_input_cols,
313
315
) ?;
314
- trans_output_exprs. push ( ExprIR :: new ( trans_node, agg. output_name_inner ( ) . clone ( ) ) ) ;
316
+ let output_name = OutputName :: Alias ( agg. output_name ( ) . clone ( ) ) ;
317
+ trans_output_exprs. push ( ExprIR :: new ( trans_node, output_name) ) ;
315
318
}
316
319
317
320
let input_schema = & phys_sm[ trans_input. node ] . output_schema ;
0 commit comments