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.
Purpose
Linked issue: close #2164
Fix
IndexOutOfBoundsExceptionwhen writing rows with array columns where the total number of array elements exceedsINITIAL_CAPACITY(1024) while the row count stays below it.Brief change log
In
ArrowWriter.writeRow(), thehandleSafeflag is determined by comparing row count againstINITIAL_CAPACITY:When
handleSafe = false, Arrow writers usevector.set()which doesn't auto-grow the buffer. The bug is inArrowArrayWriter.doWrite()which passes the parent'shandleSafeflag to the element writer. However, array element indices grow based on cumulative element count, not row count.Example: 250 rows with 10-element arrays → row count (250) < 1024 so
handleSafe = false, but total elements (2500) exceeds the vector's initial capacity, causingIndexOutOfBoundsException.Fix:
Always use safe writes (
handleSafe = true) for array element writers inArrowArrayWriter.doWrite(), since element indices can exceedINITIAL_CAPACITYindependently of row count.Tests
ArrowReaderWriterTest#testArrayWriterWithManyElements: writes 200 rows with 10-element arrays (2000 total elements), verifying serialization succeeds and data can be read back correctly.API and Format
No API or storage format changes.
Documentation
No documentation changes needed. This is a bug fix.