You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PrimitiveRunBuilder loses rows or panics when reused after finish #11325
After PrimitiveRunBuilder::finish, reusing the builder can go wrong:
If the next batch is a single run (all values equal, or all null) with the same length as the previous batch, finish returns an empty array. The appended rows are silently lost.
Calling finish again without appending anything panics. On a new builder, the same call returns an empty array.
Other batch shapes are returned correctly. StringRunBuilder handles both sequences correctly.
finish is documented as "Creates the RunArray and resets the builder", so the builder is expected to be reusable.
To Reproduce
With arrow-array = "60.0.0" (also reproduces on main):
use arrow_array::Array;use arrow_array::builder::PrimitiveRunBuilder;use arrow_array::types::{Int16Type,Int32Type};fnmain(){// A batch with the same length as the previous one, made of a single runletmut builder = PrimitiveRunBuilder::<Int16Type,Int32Type>::new();
builder.extend([Some(1),Some(2),Some(3)]);println!("first batch: len {}", builder.finish().len());
builder.extend([Some(7),Some(7),Some(7)]);println!("second batch: len {}", builder.finish().len());// Calling finish again without appending anythingletmut builder = PrimitiveRunBuilder::<Int16Type,Int32Type>::new();
builder.extend([Some(1),Some(2),Some(3)]);
builder.finish();
builder.finish();}
Output:
first batch: len 3
second batch: len 0
thread 'main' panicked at arrow-array-60.0.0/src/builder/primitive_run_builder.rs:210:64:
called `Result::unwrap()` on an `Err` value: InvalidArgumentError("The values in run_ends array should be strictly positive. Found value 0 at index 0 that does not match the criteria.")
Expected behavior
The second batch has length 3 (one run of 7), and the last finish returns an empty array, as it does on a new builder.
Activity
neilconway commentedon Oct 1, 2026
take
fix(arrow-array): `PrimitiveRunBuilder` was buggy after `finish` (apa…