Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 10 additions & 29 deletions arrow-arith/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::arithmetic::add;
use arrow_array::types::*;
use arrow_buffer::NullBuffer;
use std::sync::Arc;

#[test]
Expand Down Expand Up @@ -897,54 +897,35 @@ mod tests {

#[test]
fn test_primitive_array_sum_large_64() {
let a: Int64Array = (1..=100)
.map(|i| if i % 3 == 0 { Some(i) } else { None })
.collect();
let b: Int64Array = (1..=100)
.map(|i| if i % 3 == 0 { Some(0) } else { Some(i) })
.collect();
// create an array that actually has non-zero values at the invalid indices
let c = add(&a, &b).unwrap();
let validity = NullBuffer::new((1..=100).map(|x| x % 3 == 0).collect());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these are updated because they were testing the sum kernel for two arrays rather than the aggregate sum (which is what is defined in this module)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to avoid using a now deprecated kernel

let c = Int64Array::new((1..=100).collect(), Some(validity));

assert_eq!(Some((1..=100).filter(|i| i % 3 == 0).sum()), sum(&c));
}

#[test]
fn test_primitive_array_sum_large_32() {
let a: Int32Array = (1..=100)
.map(|i| if i % 3 == 0 { Some(i) } else { None })
.collect();
let b: Int32Array = (1..=100)
.map(|i| if i % 3 == 0 { Some(0) } else { Some(i) })
.collect();
// create an array that actually has non-zero values at the invalid indices
let c = add(&a, &b).unwrap();
let validity = NullBuffer::new((1..=100).map(|x| x % 3 == 0).collect());
let c = Int32Array::new((1..=100).collect(), Some(validity));
assert_eq!(Some((1..=100).filter(|i| i % 3 == 0).sum()), sum(&c));
}

#[test]
fn test_primitive_array_sum_large_16() {
let a: Int16Array = (1..=100)
.map(|i| if i % 3 == 0 { Some(i) } else { None })
.collect();
let b: Int16Array = (1..=100)
.map(|i| if i % 3 == 0 { Some(0) } else { Some(i) })
.collect();
// create an array that actually has non-zero values at the invalid indices
let c = add(&a, &b).unwrap();
let validity = NullBuffer::new((1..=100).map(|x| x % 3 == 0).collect());
let c = Int16Array::new((1..=100).collect(), Some(validity));
assert_eq!(Some((1..=100).filter(|i| i % 3 == 0).sum()), sum(&c));
}

#[test]
fn test_primitive_array_sum_large_8() {
// include fewer values than other large tests so the result does not overflow the u8
let a: UInt8Array = (1..=100)
.map(|i| if i % 33 == 0 { Some(i) } else { None })
.collect();
let b: UInt8Array = (1..=100)
.map(|i| if i % 33 == 0 { Some(0) } else { Some(i) })
.collect();
// create an array that actually has non-zero values at the invalid indices
let c = add(&a, &b).unwrap();
let validity = NullBuffer::new((1..=100).map(|x| x % 33 == 0).collect());
let c = UInt8Array::new((1..=100).collect(), Some(validity));
assert_eq!(Some((1..=100).filter(|i| i % 33 == 0).sum()), sum(&c));
}

Expand Down
Loading