Skip to content

RunArray::try_new rejects run ends whose null buffer has no nulls #12427

Done

Description

@mbutrovich

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, 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, and it holds there, because ArrayDataBuilder::build drops a null buffer with no nulls.

To Reproduce

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.

Activity

  1. Surajsuthar commented on Nov 27, 2026

    @Surajsuthar
    Contributor

    take

  2. added a commit that references this issue on Dec 1, 2026
    0f1fd35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions