fix(list): use valid empty offsets in ListArray::new_empty#12
Closed
JONBRWN wants to merge 1 commit into
Closed
Conversation
OffsetsBuffer::default() produces a zero-length offsets buffer, which violates the Arrow spec (N elements require N+1 offsets). When new_null_array() recurses through nested list types via new_empty_array(), every child level gets an empty offset buffer. PyArrow 14 segfaults in _table_to_blocks when it encounters these zero-length child offset buffers during to_pandas() conversion. Fixes ENG-6097 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates ListArray::new_empty to construct offsets via Offsets::new_zeroed(0) (converted into an OffsetsBuffer) instead of using OffsetsBuffer::default(), intended to ensure empty list arrays have a valid single-element [0] offsets buffer.
Changes:
- Change
ListArray::new_emptyto useOffsets::new_zeroed(0).into()for offsets initialization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
90
to
93
| pub fn new_empty(data_type: DataType) -> Self { | ||
| let values = new_empty_array(Self::get_child_type(&data_type).clone()); | ||
| Self::new(data_type, OffsetsBuffer::default(), values, None) | ||
| Self::new(data_type, Offsets::new_zeroed(0).into(), values, None) | ||
| } |
Comment on lines
90
to
93
| pub fn new_empty(data_type: DataType) -> Self { | ||
| let values = new_empty_array(Self::get_child_type(&data_type).clone()); | ||
| Self::new(data_type, OffsetsBuffer::default(), values, None) | ||
| Self::new(data_type, Offsets::new_zeroed(0).into(), values, None) | ||
| } |
Author
|
closing in favor of an in engine fix |
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.
Summary
ListArray::new_emptywas usingOffsetsBuffer::default()which produces a zero-length offsets buffer. The Arrow spec requires N+1 offsets for N elements — an empty list array (0 elements) must have a single[0]offset (4 bytes), not an empty buffer.When
new_null_array()is called on a nested list type (e.g.list<list<list<list<double>>>>), it recurses through each nesting level vianew_empty_array(), which callsnew_empty()at each level. Every child level ends up with a zero-length offset buffer, producing malformed Arrow IPC data.Root cause (ENG-6097)
The Wallaroo engine nulls
in.tensor(a 4-deep nested list column) when inference log size exceeds the byte limit. The resulting Arrow IPC bytes contain zero-length child offset buffers at every nesting level. PyArrow 14 segfaults in_table_to_blockswhento_pandas()encounters these invalid buffers.Confirmed by inspecting the raw buffers of real production data vs synthetically constructed tables — the only difference was
size=0vssize=4on child offset buffers.Fix
Replace
OffsetsBuffer::default()withOffsets::new_zeroed(0).into(), which produces a valid single-element[0]offset buffer. This propagates correctly through all nesting levels when building null arrays.🤖 Generated with Claude Code