diff --git a/arrow/src/compute/kernels/boolean.rs b/arrow/src/compute/kernels/boolean.rs index e1d5592d423c..c9c0bc3545f6 100644 --- a/arrow/src/compute/kernels/boolean.rs +++ b/arrow/src/compute/kernels/boolean.rs @@ -376,7 +376,7 @@ pub fn not(left: &BooleanArray) -> Result { 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); @@ -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::().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![