Skip to content

[59_maintenance] fix(arrow-array): preserve type params in PrimitiveArray::into_builder - #11448

Merged
alamb merged 2 commits into
apache:59_maintenancefrom
Jefffrey:backport_11310_11321
Oct 8, 2026
Merged

alamb merged 2 commits into
apache:59_maintenancefrom
Jefffrey:backport_11310_11321

Conversation

@Jefffrey

@Jefffrey Jefffrey commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

…apache#11310)

# Which issue does this PR close?

- N/A

# Rationale for this change

If `PrimitiveArray::into_builder` fails to convert the array into the
builder, we are supposed to return the input array unchanged. The
previous implementation rebuilt the array with `T::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?

* Fix bug
* Add unit test

# Are these changes tested?

Yes; existing tests pass, new test added.

# Are there any user-facing changes?

No.
…er` (apache#11321)

# Which issue does this PR close?

- Follow-on to apache#11310

# Rationale for this change

apache#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).
@Jefffrey Jefffrey added the bug Squash those bugs label Oct 8, 2026
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-array labels Oct 8, 2026

@mbutrovich mbutrovich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a clean cherry-pick. LGTM FWIW, thanks @Jefffrey!

@alamb
alamb merged commit c8a8df5 into apache:59_maintenance Oct 8, 2026
30 of 31 checks passed
@Jefffrey
Jefffrey deleted the backport_11310_11321 branch October 9, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-array bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants