fix(arrow-cast): only cast visible elements for lists and maps - #11359
Merged
Merged
Conversation
…r to Casting a List, LargeList, ListView or Map cast its whole child array, including values outside a slice. A value outside the slice that could not be cast made the cast fail with `safe: false`. With `safe: true` it became null, which still failed when the target child field was non-nullable, as map keys always are. The result also kept the whole cast child array. Cast only the range of child values that the rows span, and rebase the offsets. For ListView, rows can be in any order, so that range can still include values that no row in the slice uses.
Jefffrey
approved these changes
Oct 4, 2026
Contributor
|
thanks @neilconway |
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
Casting a List, LargeList, ListView or Map cast its whole child array. When the input to the cast was sliced, this was both inefficient and could also result in spurious errors, if a value outside the visible span made the cast fail (with
safe: false).For lists and maps, we now cast only the range of child values that the rows span, and rebase the offsets. For ListView, a row can point anywhere in the values buffer, so the visible elements might not form a contiguous span. Casting only the visible values would be expensive and require copies, so we instead settle for an overestimate: we use the lowest starting offset and highest ending offset of any row. This is an improvement over the previous behavior, but it does result in unnecessarily casting values that are inside that range but not part of any row.
What changes are included in this PR?
Are these changes tested?
Yes; existing tests pass, new tests added.
Are there any significant user-facing changes?
No.
AI usage
Developed and revised with Claude Code (Opus 5.5). I have reviewed and understand the resulting code.