Mola-maker opened a new pull request, #12251: URL: https://github.com/apache/arrow-rs/pull/12251
- Closes #12238 # Rationale for this change `NullBufferBuilder::finish` documents "Returns `None` if the builder only contains `true`s", but once the bitmap was materialized it returned `Some` even when the builder contained no nulls — for example after `append_n_nulls(0)`, or after `set_bit(i, true)` cleared the only null. `finish_cloned` and `build` behaved the same way. Kernels relying on the documented `None` to take their no-null paths would instead receive a null buffer with a zero null count. # What changes are included in this PR? - `append_n_nulls(0)` and `set_bit(i, true)` before the bitmap exists are now no-ops: neither materializes the bitmap. Out-of-bounds `set_bit` still panics, as before. - `finish`, `finish_cloned`, and `build` return `None` when `null_count() == 0`. This also covers nulls lost through `truncate` or `as_slice_mut`, and a bitmap passed to `new_from_buffer` with all bits set. `NullBuffer::new` already counts the nulls, so the check adds no work. # Are these changes tested? Yes. Six new tests in `arrow-buffer/src/builder/null.rs` covering the issue's exact repro (both the `finish`/`finish_cloned` case and the `set_bit` case), the no-materialization cases, nulls removed by `truncate` and `as_slice_mut`, an all-valid buffer from `new_from_buffer`, and the preserved out-of-bounds `set_bit` panic. Full crate suite: 386 lib tests + 92 doc tests pass. Downstream `arrow-data`, `arrow-array`, and `arrow-select` suites also pass (1609 tests total, 0 failed). `cargo fmt --check` and `cargo clippy -p arrow-buffer --all-targets --all-features -- -D warnings` are clean. # Are there any significant user-facing changes? Behavior fix only: `finish`, `finish_cloned`, and `build` now return `None` when the builder contains no nulls, as documented. No public API change. # AI usage disclosure AI assistance was used to implement the fix and tests, following the approach described in #12238; the changes were verified with the crate's test suite, clippy and fmt. -- 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]
