Repository navigation
feat(arrow/ipc): add Reader.ContinueFrom for streams split across blobs - #1346
Merged
Merged
Conversation
Since v18.8.0, a Reader that reached the end of its source stays done, so swapping the underlying io.Reader to decode a later schema-less blob yields zero rows with a nil error. ContinueFrom and ContinueFromMessageReader resume a reader on a new source, keeping the schema and dictionaries already read. A schema message where a record batch is expected now fails with a clear error instead of the generic invalid-message-type one, so a continuation that is really a new stream fails loudly rather than dropping rows. Fixes apache#1325
NewReader built its message reader without the configured WithMetadataSizeLimit/WithBodySizeLimit, so stream readers enforced no limit at all, and ContinueFrom applied the defaults instead of the reader's own limits. Both now use the limits the Reader was created with.
lidavidm
approved these changes
Oct 5, 2026
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.
Rationale for this change
Fixes #1325. Some callers decode one logical IPC stream that arrives as a sequence of blobs, where only the first blob carries the schema. Through v18.7.0 they could reuse one
ipc.Readerby swapping the underlyingio.Reader. Since v18.8.0,donestays set once a blob reaches EOF and can't be reset, so every blob after the first decodes as zero rows with a nil error.What changes are included in this PR?
(*Reader).ContinueFrom(io.Reader) errorand(*Reader).ContinueFromMessageReader(MessageReader) errorresume a reader on a new source. The schema and dictionaries already read are kept. Both methods also:done;arrow/ipc: unexpected schema message: …. That marks the reader done, and the error is sticky. Before, this gave the generic invalid-message-type error. The other invalid-type errors now also have their closing parenthesis back.Are these changes tested?
Yes.
TestReaderContinueFromsplits a single writer's output, with an int64 column and a dictionary column, into three blobs and checks:NextandRead, and dictionaries carry across blobs;ContinueFromon a reader whose schema hasn't been read yet returns an error and leaves the reader usable.The test uses a checked allocator. Removing the
donereset makes it fail.Are there any user-facing changes?
Yes: two new methods on
ipc.Reader, and a clearer error when a schema message appears mid-stream.Message size limits (follow-up commit)
NewReaderbuilt itsmessageReaderwithout the configured limits. Those limits were added in #955, which never touchedreader.go, so a streamReaderignoredWithMetadataSizeLimit/WithBodySizeLimitand enforced no limit at all.NewReadernow creates its message reader with the options it was given, andContinueFromreuses the same limits.Behavior change: stream readers created with
NewReadernow enforce the documented default limits, 64 MiB for metadata and 256 MiB for bodies. A stream with larger messages needsWithBodySizeLimit/WithMetadataSizeLimit; passing a value ≤ 0 disables the limit.TestReaderSizeLimitscovers bothNewReaderandContinueFrom.