tustvold commented on code in PR #6800:
URL: https://github.com/apache/arrow-datafusion/pull/6800#discussion_r1252108021
##########
datafusion/physical-expr/src/aggregate/average.rs:
##########
@@ -155,6 +160,35 @@ impl AggregateExpr for Avg {
&self.rt_data_type,
)?))
}
+
+ fn create_groups_accumulator(&self) -> Result<Box<dyn GroupsAccumulator>> {
+ // instantiate specialized accumulator
+ match (&self.sum_data_type, &self.rt_data_type) {
+ (
+ DataType::Decimal128(_sum_precision, sum_scale),
+ DataType::Decimal128(target_precision, target_scale),
+ ) => {
+ let decimal_averager = Decimal128Averager::try_new(
+ *sum_scale,
+ *target_precision,
+ *target_scale,
+ )?;
+
+ let avg_fn =
+ move |sum: i128, count: u64| decimal_averager.avg(sum,
count as i128);
+
+ Ok(Box::new(AvgGroupsAccumulator::<Decimal128Type, _>::new(
Review Comment:
This also serves the purpose of allowing us to eventually deprecate the
ScalarValue binary operations -
https://github.com/apache/arrow-datafusion/issues/6842
--
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]