Skip to content

Commit

Permalink
Fix bug with null buffer offset in boolean not kernel (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhorstmann authored Jun 8, 2021
1 parent 5adfd3d commit 015ee75
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion arrow/src/compute/kernels/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub fn not(left: &BooleanArray) -> Result<BooleanArray> {
let null_bit_buffer = data
.null_bitmap()
.as_ref()
.map(|b| b.bits.slice(left_offset));
.map(|b| b.bits.bit_slice(left_offset, len));

let values = buffer_unary_not(&data.buffers()[0], left_offset, len);

Expand Down Expand Up @@ -813,6 +813,19 @@ mod tests {
assert_eq!(c, expected);
}

#[test]
fn test_bool_array_not_sliced() {
let a = BooleanArray::from(vec![None, Some(true), Some(false), None, Some(true)]);
let a = a.slice(1, 4);
let a = a.as_any().downcast_ref::<BooleanArray>().unwrap();
let c = not(&a).unwrap();

let expected =
BooleanArray::from(vec![Some(false), Some(true), None, Some(false)]);

assert_eq!(c, expected);
}

#[test]
fn test_bool_array_and_nulls() {
let a = BooleanArray::from(vec![
Expand Down

0 comments on commit 015ee75

Please sign in to comment.