Skip to content

fix(arrow-cast): respect sliced list offsets in fixed-size list casts - #11065

Open
CodingCossack wants to merge 1 commit into
apache:mainfrom
CodingCossack:fix/10975-sliced-list-cast
Open

fix(arrow-cast): respect sliced list offsets in fixed-size list casts#11065
CodingCossack wants to merge 1 commit into
apache:mainfrom
CodingCossack:fix/10975-sliced-list-cast

Conversation

@CodingCossack

Copy link
Copy Markdown

Which issue does this PR close?

Closes #10975.

Rationale for this change

Slicing a ListArray or LargeListArray retains offsets into the original
child array. Casting the slice to FixedSizeList currently reads from child
position zero on the fast path and when copying the first pending run on
the padding path. This can return excluded values or overfill the padded
output.

What changes are included in this PR?

Start child selection and the first pending copy at the first retained
offset. Replace the numeric cursor sentinel and first-row special case
with Option, distinguishing no replacement from a valid source
position, including for empty rows.

Preserve the existing safe/strict length handling and perform child
conversion after selecting or padding the retained rows.

Are these changes tested?

Three regression tests cover both list offset widths, fast and padding
paths, non-zero offsets, excluded values during child conversion, nulls,
safe/strict behaviour, empty slices and zero-width output.

Local validation executed by Codex:

  • All three regression tests failed before the fix and passed afterwards.
  • cargo test -p arrow-cast --all-features: 425 unit tests and 15 doctests passed.
  • cargo test -p arrow-cast --release --lib --tests: 382 tests passed.
  • Strict Clippy, unused-dependency checks, formatting, spelling and
    git diff --check passed.

Are there any user-facing changes?

Affected sliced List and LargeList casts now select the correct child
values and avoid padding-path overfill. No public API changes.

AI assistance

OpenAI Codex generated the implementation and regression tests and ran
the local validation. ChatGPT assisted with an independent static review
and this PR description.

@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-cast labels Sep 12, 2026
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-cast

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Casting a sliced list to FixedSizeList silently returns the wrong values

1 participant