From e64c9eb0eec3744655ce166146f3ee1930ff542e Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Wed, 9 Jun 2021 14:10:42 -0400 Subject: [PATCH] Fix bug with null buffer offset in boolean not kernel (#418) (#434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jörn Horstmann --- arrow/src/compute/kernels/boolean.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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![