refactor(parquet-datasource): extract DecoderProjection from build_stream#22398
Merged
Conversation
…ream `RowGroupsPrunedParquetOpen::build_stream` used to inline the `build_projection_read_plan` + `reassign_expr_columns` + `make_projector` + `replace_schema` quartet right next to the decoder / stream wiring, which made the opener's main orchestration body harder to follow. Move that block into a new `decoder_projection` module exposing a single `DecoderProjection::build(projection, physical_file_schema, parquet_schema, output_schema)` entry point. The struct keeps its fields private and exposes: * `projection_mask()` for the decoder builder, and * `map(&batch)` which applies the projector and, when needed, rebuilds the batch with `output_schema` to recover metadata / nullability the file schema does not carry. This collapses three fields on `PushDecoderStreamState` (`projector`, `output_schema`, `replace_schema`) into a single `decoder_projection: DecoderProjection`, and lets `project_batch` delegate to `DecoderProjection::map`. `replace_schema` is derived from the projector's output schema (rather than the read plan's projected schema) so it stays correct under future widening of the decoder mask. `DecoderBuilderConfig` now carries the projection mask directly (`projection_mask: &ProjectionMask`) instead of the full `ParquetReadPlan`, since the read plan's `projected_schema` is no longer needed in this layer. No behaviour change. All existing parquet tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@xudong963 another PR to factor complexity out of the opener 🙏🏻 |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
xudong963
approved these changes
May 21, 2026
Co-authored-by: xudong.w <wxd963996380@gmail.com>
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.
Which issue does this PR close?
Rationale for this change
RowGroupsPrunedParquetOpen::build_streaminlines thebuild_projection_read_plan+reassign_expr_columns+make_projector+replace_schemaquartet right next to the decoder / stream wiring, which makes the opener's main orchestration body harder to follow and mixes two concerns: building the per-file projection vs. wiring it through the push-decoder stream.This PR isolates that block behind a small
DecoderProjectiontype whose public surface is just "give me the projection mask" and "project this decoded batch onto the output schema."What changes are included in this PR?
decoder_projectionmodule with aDecoderProjectiontype:DecoderProjection::try_new(projection, physical_file_schema, parquet_schema, output_schema)constructs the per-file projection in one call.projection_mask()returns the mask installed on every decoder run.map(&batch)applies the projector and, when needed, rebuilds the batch withoutput_schemato recover metadata / nullability that the file schema does not carry.PushDecoderStreamStatecollapses three fields (projector,output_schema,replace_schema) into a singledecoder_projection: DecoderProjection.project_batchbecomes a one-line delegate toDecoderProjection::map.replace_schemais now derived from the projector's output schema (rather than the read plan's projected schema) so it stays correct under future widening of the decoder mask.DecoderBuilderConfigcarries the projection mask directly (projection_mask: &ProjectionMask) instead of the fullParquetReadPlan, since the read plan'sprojected_schemais no longer needed in this layer.No behaviour change.
Are these changes tested?
Covered by existing tests:
Are there any user-facing changes?
No. All affected types are `pub(crate)`.
🤖 Generated with Claude Code