Skip to content

Commit

Permalink
Add float support for sum
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniël Heres committed Jul 5, 2023
1 parent ad6d4f3 commit 87b54c9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion datafusion/physical-expr/src/aggregate/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ use arrow::{
datatypes::Field,
};
use arrow_array::cast::AsArray;
use arrow_array::types::{Decimal128Type, Int32Type, Int64Type, UInt32Type, UInt64Type};
use arrow_array::types::{
Decimal128Type, Float32Type, Float64Type, Int32Type, Int64Type, UInt32Type,
UInt64Type,
};
use arrow_array::{ArrowNativeTypeOp, ArrowNumericType, PrimitiveArray};
use datafusion_common::{downcast_value, DataFusionError, Result, ScalarValue};
use datafusion_expr::Accumulator;
Expand Down Expand Up @@ -171,6 +174,14 @@ impl AggregateExpr for Sum {
&self.data_type,
&self.data_type,
))),
DataType::Float32 => Ok(Box::new(SumGroupsAccumulator::<Float32Type>::new(
&self.data_type,
&self.data_type,
))),
DataType::Float64 => Ok(Box::new(SumGroupsAccumulator::<Float64Type>::new(
&self.data_type,
&self.data_type,
))),
DataType::Decimal128(_target_precision, _target_scale) => {
Ok(Box::new(SumGroupsAccumulator::<Decimal128Type>::new(
&self.data_type,
Expand Down

0 comments on commit 87b54c9

Please sign in to comment.