alamb commented on code in PR #25536:
URL: https://github.com/apache/datafusion/pull/25536#discussion_r4063654259
##########
datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs:
##########
@@ -187,7 +191,10 @@ fn rewrite_aggregate_non_aggregate_aggr_expr(
return Ok(Transformed::no(plan));
};
- let rewrote_aggs = rewrite_multiple_linear_aggregates(&mut aggr_expr)?;
+ let rewrote_linear = rewrite_multiple_linear_aggregates(&mut aggr_expr)?;
Review Comment:
I think our CSE pass already does something like this 🤔
##########
datafusion/expr/src/udaf.rs:
##########
@@ -311,6 +312,17 @@ impl AggregateUDF {
self.inner.simplify()
}
+ /// Returns this aggregate function's candidate decomposition, if any.
+ ///
+ /// See [`AggregateUDFImpl::decompose`] for more details.
+ pub fn decompose(
Review Comment:
I wonder if you considered using the existing `simplify` method:
https://docs.rs/datafusion/latest/datafusion/logical_expr/trait.AggregateUDFImpl.html#method.simplify
If you changed the avg udf to simplify to `sum/count` the existing common
subexpr eliminate path probably will already avoid the recomputation.
Also it woudl allow us to delete the actual AVG accumulators (rather than
having a special case like this) 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]