Skip to content

GH-10676: Fix IPC StreamReader projected schema - #10677

Merged
Jefffrey merged 1 commit into
apache:mainfrom
codeAnqiang-ma:fix/ipc-stream-reader-projected-schema
Aug 15, 2026
Merged

GH-10676: Fix IPC StreamReader projected schema#10677
Jefffrey merged 1 commit into
apache:mainfrom
codeAnqiang-ma:fix/ipc-stream-reader-projected-schema

Conversation

@codeAnqiang-ma

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

With a projection set, StreamReader yields batches with the projected schema, but StreamReader::schema() and its RecordBatchReader::schema() impl return the full stream schema. Same as #10382 (csv) and #10613 (ipc file reader); #10627 fixed FileReader, StreamReader was the remaining case.

What changes are included in this PR?

  • Keep the projected schema StreamReader::try_new already computes as a SchemaRef and return it from StreamReader::schema(); the RecordBatchReader impl delegates to it, as FileReader does.
  • Decoding is untouched: batch and dictionary decoding still use the full stream schema, and with no projection the reported schema is unchanged.
  • Add a regression test mirroring test_file_reader_projected_schema_matches_batch_schema.

Are these changes tested?

Yes, the new test fails before this change (14 column stream schema vs 3 column batch schema) and passes after. I ran:

  • cargo test -p arrow-ipc (143 passed) and --all-features (148 passed)
  • cargo clippy -p arrow-ipc --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check

I did not run the full workspace suite; outside arrow-ipc every StreamReader::try_new call site passes None, which is unaffected.

Are there any user-facing changes?

Yes. A projected IPC StreamReader now reports the same schema as the batches it produces. No public API signature changes.

AI assistance: an AI agent found this by auditing the remaining RecordBatchReader impls after #10613 and drafted the fix and its test; I reviewed every line and ran the reproduction and the checks above locally.

When a projection is set, StreamReader::schema() returned the full stream
schema while the batches it produces carry the projected schema, breaking
the RecordBatchReader contract. Return the projected schema that try_new
already computes, mirroring the FileReader fix in apache#10627.

Assisted-by: Cursor (Opus 5)
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-ipc labels Aug 13, 2026
Comment thread arrow-ipc/src/reader.rs
Comment on lines +1632 to +1635
match &self.projection {
Some((_, projected_schema)) => projected_schema.clone(),
None => self.schema.clone(),
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Jefffrey Jefffrey added the bug label Aug 14, 2026
@Jefffrey
Jefffrey merged commit 2cc31af into apache:main Aug 15, 2026
34 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @codeAnqiang-ma & @Rich-T-kid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-ipc bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ipc stream reader RecordBatchReader::schema ignores column projection

3 participants