Skip to content

fix: Reject a second Schema message in an IPC stream - #564

Draft
Sealdot wants to merge 1 commit into
apache:mainfrom
Sealdot:fix-ipc-second-schema-563
Draft

Sealdot wants to merge 1 commit into
apache:mainfrom
Sealdot:fix-ipc-second-schema-563

Conversation

@Sealdot

@Sealdot Sealdot commented Dec 4, 2026

Copy link
Copy Markdown

Closes #563.

An Arrow IPC stream carries one Schema message, at its start. The stream reader accepted a second Schema message anywhere in the stream: RecordBatchStreamReaderImpl.next() (and its async counterpart) called this.reset(message.header()) for every Schema message, which replaced the schema and dropped the dictionaries mid-stream. As the repro in #563 shows, inserting an Int32 schema between the DictionaryBatch and the RecordBatch of a dictionary stream makes the column read as its raw indices [0, 1, 0] with no error.

The reader now throws Expected a DictionaryBatch or RecordBatch message in the IPC stream, but was a second Schema message. when a Schema message arrives after a schema is already in place — whether read through open(), or lazily through a first next() on an unopened reader (that lazy path, used by iteration and the stream adapters, still consumes the stream's first Schema message). The file readers are unaffected: they index record batch blocks through the footer and never see Schema messages in next().

The regression tests split real writer output into messages and reassemble streams with a second Schema after the dictionary batch, after the first record batch, or right after the first Schema — all now raise the error in the sync reader, and the async reader rejects in next(). A valid dictionary stream still reads ['a', 'b', 'a'], and lazy iteration of an unopened reader still works.

All 2,979 IPC tests across 20 suites passed on main (7a34e681), along with ESLint on both changed files; tsc --noEmit reports no errors in src/ or the new test file (the repo's test-suite typecheck carries unrelated pre-existing errors, e.g. ix/ module resolution). 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 stream delivers a Schema message after its schema is already set, instead of silently replacing the schema and dropping the dictionaries. The lazy first-read path still consumes the stream's initial Schema message.

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 stream reader accepts a second Schema message: a dictionary column reads as its indices [0, 1, 0], with no error

1 participant