Skip to content

arrow-ipc: Ensure writer conforms to spec on length-0 variable-size arrays#9717

Open
atwam wants to merge 1 commit intoapache:mainfrom
atwam:fix-empty-utf8-buffers
Open

arrow-ipc: Ensure writer conforms to spec on length-0 variable-size arrays#9717
atwam wants to merge 1 commit intoapache:mainfrom
atwam:fix-empty-utf8-buffers

Conversation

@atwam
Copy link
Copy Markdown
Contributor

@atwam atwam commented Apr 14, 2026

Which issue does this PR close?

Rationale for this change

Current version serializes a length-0 offsets buffer, and relies on the array constructor to set offsets to [0] for empty arrays. This does not conform with spec, which specifies that the offsets buffer should have length + 1 elements.

This correctly serializes a length-1 offsets buffer containing [0]. I have left the current behavior of filling-in offsets with [0] for empty arrays, so that future versions can still read IPC files serialized by previous versions.

What changes are included in this PR?

Added tests for serialization of empty arrays, ensuring length-1 offsets buffer. Fixed serialization of empty arrays.
This fixes serialization of empty Binary/Utf8/List/LargeList (and Map) arrays.

Are these changes tested?

Yes

Are there any user-facing changes?

There should not be any breaking change for users. Serialized files for empty record batches will be slightly different. Older serialized files should still be read fine.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 14, 2026
@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 14, 2026

Current version serializes a length-0 offsets buffer, and relies on the array constructor to set offsets to [0] for empty arrays. This does not conform with spec, which specifies that the offsets buffer should have length + 1 elements.

I don't understand this statement. The spec you reference in #9716 is for the in memory structure (not the ipc format)

It almost sounds like a bug in polars -- shouldn't it accept zero length IPC buffers ?

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.

arrow-ipc writer does not comply with spec for empty variable-size arrays

2 participants