Skip to content

Commit

Permalink
wip (#5167)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchao authored Feb 3, 2023
1 parent c759865 commit 1ec2a83
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions datafusion/physical-expr/src/aggregate/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,10 @@ macro_rules! typed_sum_delta_batch {
}};
}

// TODO implement this in arrow-rs with simd
// https://github.com/apache/arrow-rs/issues/1010
fn sum_decimal_batch(values: &ArrayRef, precision: u8, scale: i8) -> Result<ScalarValue> {
let array = downcast_value!(values, Decimal128Array);

if array.null_count() == array.len() {
return Ok(ScalarValue::Decimal128(None, precision, scale));
}

let result = array.into_iter().fold(0_i128, |s, element| match element {
Some(v) => s + v,
None => s,
});

Ok(ScalarValue::Decimal128(Some(result), precision, scale))
let result = compute::sum(array);
Ok(ScalarValue::Decimal128(result, precision, scale))
}

// sums the array and returns a ScalarValue of its corresponding type.
Expand Down

0 comments on commit 1ec2a83

Please sign in to comment.