AdamGS commented on code in PR #22714:
URL: https://github.com/apache/datafusion/pull/22714#discussion_r3364195676
##########
datafusion/functions-aggregate/src/average.rs:
##########
@@ -223,50 +233,48 @@ impl AggregateUDFImpl for Avg {
match (&data_type, acc_args.return_type()) {
(Float64, Float64) => Ok(Box::<AvgAccumulator>::default()),
(
- Decimal32(sum_precision, sum_scale),
+ Decimal32(_sum_precision, sum_scale),
Decimal32(target_precision, target_scale),
- ) => Ok(Box::new(DecimalAvgAccumulator::<Decimal32Type> {
- sum: None,
- count: 0,
- sum_scale: *sum_scale,
- sum_precision: *sum_precision,
- target_precision: *target_precision,
- target_scale: *target_scale,
- })),
+ ) => Ok(Box::new(DecimalAvgAccumulator::<
+ Decimal32Type,
+ Decimal64Type,
+ >::new(
+ *sum_scale,
+ DECIMAL64_MAX_PRECISION,
+ *target_precision,
+ *target_scale,
+ ))),
(
- Decimal64(sum_precision, sum_scale),
+ Decimal64(_sum_precision, sum_scale),
Decimal64(target_precision, target_scale),
- ) => Ok(Box::new(DecimalAvgAccumulator::<Decimal64Type> {
- sum: None,
- count: 0,
- sum_scale: *sum_scale,
- sum_precision: *sum_precision,
- target_precision: *target_precision,
- target_scale: *target_scale,
- })),
+ ) => Ok(Box::new(DecimalAvgAccumulator::<
+ Decimal64Type,
+ Decimal128Type,
+ >::new(
+ *sum_scale,
+ DECIMAL128_MAX_PRECISION,
+ *target_precision,
+ *target_scale,
+ ))),
(
Decimal128(sum_precision, sum_scale),
Decimal128(target_precision, target_scale),
- ) => Ok(Box::new(DecimalAvgAccumulator::<Decimal128Type> {
- sum: None,
- count: 0,
- sum_scale: *sum_scale,
- sum_precision: *sum_precision,
- target_precision: *target_precision,
- target_scale: *target_scale,
- })),
+ ) => Ok(Box::new(DecimalAvgAccumulator::<Decimal128Type>::new(
Review Comment:
So it currently doesn't compile because the current code here assumes that
the type we use for the sum can be `Into<I>`, but turns out that doesn't exist
for `i256` and `i128`, I opened a
[PR](https://github.com/apache/arrow-rs/issues/10080) to arrow, which might
delay this part but I'll fix everything else.
--
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]