Skip to content

Commit

Permalink
Fix bug with null buffer offset in boolean not kernel (#418) (#434)
Browse files Browse the repository at this point in the history
Co-authored-by: Jörn Horstmann <git@jhorstmann.net>
  • Loading branch information
alamb and jhorstmann authored Jun 9, 2021
1 parent 5b80035 commit e64c9eb
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 e64c9eb

Please sign in to comment.