tustvold commented on code in PR #7358:
URL: https://github.com/apache/arrow-datafusion/pull/7358#discussion_r1300746545
##########
datafusion/physical-expr/src/aggregate/average.rs:
##########
@@ -106,11 +100,29 @@ impl AggregateExpr for Avg {
}
fn create_accumulator(&self) -> Result<Box<dyn Accumulator>> {
- Ok(Box::new(AvgAccumulator::try_new(
- // avg is f64 or decimal
- &self.sum_data_type,
- &self.rt_data_type,
- )?))
+ use DataType::*;
+ // instantiate specialized accumulator based for the type
+ match (&self.sum_data_type, &self.rt_data_type) {
+ (Float64, Float64) => {
+ Ok(Box::new(AvgAccumulator::new(self.pre_cast_to_sum_type)))
Review Comment:
This whole precast thing seems like a hack, imo this should be being handled
by the type coercion machinery, not internal to the aggregator...
--
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]