Skip to content

fix(ipc): correct skip_field handling for V4 Union#9829

Open
pchintar wants to merge 1 commit intoapache:mainfrom
pchintar:ipc-union-skip-v4
Open

fix(ipc): correct skip_field handling for V4 Union#9829
pchintar wants to merge 1 commit intoapache:mainfrom
pchintar:ipc-union-skip-v4

Conversation

@pchintar
Copy link
Copy Markdown
Contributor

@pchintar pchintar commented Apr 25, 2026

Which issue does this PR close?

Rationale for this change

Currently, skip_field does not correctly handle the buffer layout of Union types for V4 IPC.

In V4:

  • Union includes a null buffer + type_ids (+ offsets for dense)

In V5:

  • Union has no null buffer, only type_ids (+ offsets for dense)

create_array correctly handles this difference using a version check. However, skip_field always assumes a null buffer and does not skip type_ids, leading to buffer misalignment when skipping a Union column in V4.

This can cause incorrect decoding or runtime errors for projected columns.

What changes are included in this PR?

  • Updated skip_field in arrow-ipc/src/reader.rs to:

    • conditionally skip the null buffer only for V4
    • explicitly skip the type_ids buffer
    • correctly handle dense vs sparse offsets
  • Aligns skip_field behavior with create_array and actual IPC layout

Are these changes tested?

Yes.

  • Added test: test_projection_skip_union_v4

  • The test:

    • writes IPC data using V4 metadata
    • includes a Union column followed by an Int32 column
    • reads only the second column (skipping the Union)
    • verifies the output matches expected values
  • The test fails before the fix and passes after

  • All existing arrow-ipc tests pass (cargo test -p arrow-ipc --lib)

Are there any user-facing changes?

No.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Apr 25, 2026
@pchintar
Copy link
Copy Markdown
Contributor Author

cc @alamb

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect buffer skipping for V4 Union types in IPC skip_field

1 participant