Repository navigation
fix: Avoid dropping type parameters in PrimitiveArray::into_builder - #11310
Merged
Jefffrey merged 1 commit intoOct 1, 2026
Merged
Conversation
Jefffrey
approved these changes
Oct 1, 2026
Contributor
|
thanks, nice spot |
Jefffrey
pushed a commit
that referenced
this pull request
Oct 2, 2026
…er` (#11321) # Which issue does this PR close? - Follow-on to #11310 # Rationale for this change #11310 made the `Err` path of `PrimitiveArray::into_builder` return the array with its original data type. Looking closer, the `Ok` path still built the builder with `PrimitiveBuilder::new_from_buffer`, which uses `T::DATA_TYPE`, so `into_builder()?.finish()` lost type parameters. These public APIs use `PrimitiveArray::into_builder` and will now behave correctly: - `PrimitiveArray::unary_mut` and `try_unary_mut` - `binary_mut` and `try_binary_mut` in arrow-arith - `DictionaryArray::unary_mut` and `into_primitive_dict_builder` - `PrimitiveRunBuilder::finish_cloned` # What changes are included in this PR? * Ensure success path of `PrimitiveArray::into_builder` also preserves type parameters * Update unit tests * Add new unit tests for some of the public APIs above, where the behavior is non-trivial # Are these changes tested? Yes; existing tests pass, new test added. # Are there any user-facing changes? No, aside from the bug fix. # AI usage Developed with Claude Code (Fable 5.1).
This was referenced Oct 3, 2026
alamb
added a commit
that referenced
this pull request
Oct 22, 2026
…Array::into_builder` (#11807) - Backport #11310 and #11321 - For inclusion in #11666 Cherry-pick of 2f3cd82 and 38054b7 These are combined into a single PR since the fixes work on the same function ## NOTE We also backport #9473 183f8c1 since we needed it for a test, and I think fix makes more sense with this in mind. It was introduced in 58 so only 57 needs this extra backport --------- Co-authored-by: Neil Conway <[email protected]> Co-authored-by: Bruno <[email protected]> Co-authored-by: Andrew Lamb <[email protected]>
gafiatulin
pushed a commit
to gafiatulin/arrow-rs
that referenced
this pull request
Nov 14, 2026
…ion (apache#12242) # Which issue does this PR close? - Closes apache#11300 # Rationale for this change `null_if_overflow_precision` returned the default type of the decimal width instead of the input's type. A `Decimal128(2, 1)` holding `9.9` came back as `Decimal128(38, 10)` and read as `0.0000000099`. All four decimal widths behave this way, because the result is built through `unary_opt`, which uses `T::DATA_TYPE`. apache#11310 and apache#11321 fixed the same kind of bug. # What changes are included in this PR? - Set the input's data type on the `unary_opt` result with `.with_data_type(self.data_type().clone())`, as `into_builder` does since apache#11321. # Are these changes tested? Yes. `test_null_if_overflow_precision_keeps_data_type` covers Decimal32/64/128/256 at `(2, 1)`. Without the fix it fails with `Decimal32(9, 2)` vs `Decimal32(2, 1)`. # Are there any significant user-facing changes? The output data type now matches the input, including precision and scale. Which values get nulled is unchanged. Callers that re-applied the type afterwards (for example with `.with_precision_and_scale(..)`) keep working. # AI usage disclosure The patch and test were written with an AI coding agent (Claude Code). It reproduced the issue on main, ran fmt, clippy, the arrow-array tests (including release mode) and typos, and a separate agent session re-checked the fix against all four decimal widths, nulls, slices and the precision bounds before I submitted it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
If
PrimitiveArray::into_builderfails to convert the array into the builder, we are supposed to return the input array unchanged. The previous implementation rebuilt the array withT::DATA_TYPE, which doesn't preserve type parameters (like the scale/precision of a decimal, or the timezone of a timestamp).What changes are included in this PR?
Are these changes tested?
Yes; existing tests pass, new test added.
Are there any user-facing changes?
No.