mingmwang commented on code in PR #5973:
URL: https://github.com/apache/arrow-datafusion/pull/5973#discussion_r1164775086
##########
datafusion/physical-expr/src/aggregate/average.rs:
##########
@@ -298,16 +305,40 @@ impl RowAccumulator for AvgRowAccumulator {
}
fn evaluate(&self, accessor: &RowAccessor) -> Result<ScalarValue> {
- assert_eq!(self.sum_datatype, DataType::Float64);
- Ok(match accessor.get_u64_opt(self.state_index()) {
- None => ScalarValue::Float64(None),
- Some(0) => ScalarValue::Float64(None),
- Some(n) => ScalarValue::Float64(
- accessor
- .get_f64_opt(self.state_index() + 1)
- .map(|f| f / n as f64),
- ),
- })
+ match self.sum_datatype {
+ DataType::Decimal128(p, s) => {
+ match accessor.get_u64_opt(self.state_index()) {
+ None => Ok(ScalarValue::Decimal128(None, p, s)),
+ Some(0) => Ok(ScalarValue::Decimal128(None, p, s)),
Review Comment:
I will do some test on this today.
--
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]