Skip to content

fix: Reject record batch columns shorter than the batch - #561

Draft
Sealdot wants to merge 1 commit into
apache:mainfrom
Sealdot:fix-ipc-column-length-mismatch-557
Draft

Sealdot wants to merge 1 commit into
apache:mainfrom
Sealdot:fix-ipc-column-length-mismatch-557

Conversation

@Sealdot

@Sealdot Sealdot commented Dec 2, 2026

Copy link
Copy Markdown

Closes #557.

The IPC reader never compared the length of a field node with the row count of its RecordBatch. A column that declared fewer rows than the batch read with no error: ensureSameLengthData() made the field nullable and backfilled the missing rows with nulls the writer never wrote, so a reader cannot tell them from real nulls. Arrow C++ refuses such a column in RecordBatch::Validate().

_loadRecordBatch() now throws when a loaded column's length differs from header.length, before the RecordBatch constructor can backfill. This applies to both the stream and file readers, and to compressed batches (the node list is unchanged by decompression). Dictionary batches and top-level batch structure are untouched; nested child vectors may still differ in length from the batch, as the format allows.

The regression tests patch one field-node length inside otherwise valid streams and files written by the real writers — a column declaring 2 or 0 rows in a 4-row batch now raises an error naming the column, while the unmodified bytes still read correctly. The open PR #551 validates buffer regions and does not cover this fault: the buffers of these streams are unchanged.

All 2,688 IPC tests across 19 suites passed on main (7a34e681), along with the ESNext ESM source typecheck and ESLint on both changed files. A full local Jest run was not attempted; on the same machine the suite previously reached its 640 MiB Node heap limit. Upstream CI workflows await maintainer approval and have not run.

Cognition Devin CLI agent (SWE-2 High) assisted with the implementation, tests, and verification.

Throw when a field node declares a length other than the record batch row count instead of backfilling the column with nulls.

AI assistance: Cognition Devin CLI agent (SWE-2 High).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The IPC reader accepts a column that is shorter than its RecordBatch, and fills the missing rows with nulls

1 participant