mbutrovich opened a new issue, #12427:
URL: https://github.com/apache/arrow-rs/issues/12427

   ### Describe the bug
   
   `RunArray::try_new` returns "Found null values in run_ends array" when 
`run_ends` has a null buffer with a null count of 0. [It checks whether a null 
buffer is 
present](https://github.com/apache/arrow-rs/blob/6a3f719f1de43137f0ecc2e7de12d4a7a0b13bd5/arrow-array/src/array/run_array.rs#L176-L182),
 not whether any value is null. A `PrimitiveArray` can carry such a buffer: 
`PrimitiveArray::new` with `NullBuffer::new_valid`, `slice` of an array whose 
nulls fall outside the slice, and `concat` of a single array all produce one.
   
   [`ArrayData` validation has the same 
check](https://github.com/apache/arrow-rs/blob/6a3f719f1de43137f0ecc2e7de12d4a7a0b13bd5/arrow-data/src/data.rs#L1375-L1379),
 and it holds there, because `ArrayDataBuilder::build` [drops a null buffer 
with no 
nulls](https://github.com/apache/arrow-rs/blob/6a3f719f1de43137f0ecc2e7de12d4a7a0b13bd5/arrow-data/src/data.rs#L2465).
   
   ### To Reproduce
   
   ```rust
   use arrow_array::types::Int32Type;
   use arrow_array::{Array, Int32Array, RunArray};
   use arrow_buffer::NullBuffer;
   
   fn main() {
       let run_ends = Int32Array::new(vec![2, 3].into(), 
Some(NullBuffer::new_valid(2)));
       let values = Int32Array::from(vec![7, 8]);
       println!("{}", run_ends.null_count());
       // 0
       println!("{:?}", RunArray::<Int32Type>::try_new(&run_ends, 
&values).map(|a| a.len()));
       // Err(InvalidArgumentError("Found null values in run_ends array. The 
run_ends array should not have null values."))
   }
   ```
   
   ### Expected behavior
   
   `Ok(3)`. Checking `run_ends.null_count() != 0` instead of 
`run_ends.nulls().is_some()` would accept it and still reject run ends that 
hold a null.
   
   ### Additional context
   
   #12420 makes `cast` to the same type, `shift` by 0, and `nullif` of an empty 
array return the input's null buffer instead of dropping one with no nulls, so 
their output reaches this check more often.
   
   Found while checking #12420 with property-based tests, on `main` at 
`6a3f719f`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to