Skip to content

feat: Add row-group-local RowSelection support to the push decoder - #10702

Open
haohuaijin wants to merge 1 commit into
apache:mainfrom
haohuaijin:push-decoder-row-group-selections
Open

feat: Add row-group-local RowSelection support to the push decoder#10702
haohuaijin wants to merge 1 commit into
apache:mainfrom
haohuaijin:push-decoder-row-group-selections

Conversation

@haohuaijin

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

DataFusion makes row-group-local selection decisions (ParquetAccessPlan), but the reader APIs only accept selected row groups plus a single global RowSelection. Callers must concatenate per-row-group selections into one global selection, which arrow-rs then re-partitions back into per-row-group selections during decoding. This round trip is wasted work and loses each selection's representation (bitmap vs. selector).

What changes are included in this PR?

  • New public API on the push decoder: RowGroupSelection (a row group index plus an optional row-group-local RowSelection) and ParquetPushDecoderBuilder::with_row_group_selections. Entries decode in the supplied order, omitted row groups are skipped, None reads the whole row group, and each selection keeps its bitmap or selector representation.
  • Mutually exclusive with with_row_groups / with_row_selection: the setters share an internal state machine (RowGroupPlan) that reports conflicting combinations as an error from build() regardless of call order. The legacy API combination is unchanged.
  • build() validates per-row-group plans eagerly: out-of-bounds indices and selections longer than their row group are errors; shorter selections skip the trailing rows.
  • ParquetPushDecoder::into_builder preserves remaining local selections (still in local coordinates), so adaptive scans compose with the new API.
  • Minor behavior improvement: an out-of-bounds index from with_row_groups on the push decoder now returns a ParquetError during decoding instead of panicking.

The sync and async builders are unchanged; the async builder already delegates to the push decoder, so extending the API to it is a small follow-up if needed.

Are these changes tested?

Yes, new tests cover bitmap- and selector-backed local selections (including out-of-order row groups and short selections), skip/replace semantics, mutual exclusion in all four call orders, build-time validation, into_builder round-trips, and the unchanged legacy combination. All existing tests pass.

Are there any user-facing changes?

New public API: RowGroupSelection and ParquetPushDecoderBuilder::with_row_group_selections, with doc examples. No breaking changes; one behavior change: out-of-bounds with_row_groups indices on the push decoder now error during decoding instead of panicking.

@github-actions github-actions Bot added the parquet Changes to the parquet crate label Aug 15, 2026
@haohuaijin haohuaijin changed the title parquet: Add row-group-local RowSelection support to the push decoder feat: Add row-group-local RowSelection support to the push decoder Aug 15, 2026
@haohuaijin

Copy link
Copy Markdown
Contributor Author

In my mind the trick will be how to mesh the existing apis (with_row_groups and with_row_selection) and make sure we have a coherent documentation of what will happen if the user calls each one

This PR adds ParquetPushDecoderBuilder::with_row_group_selections so callers can supply row-group-local RowSelections directly. The new configuration is mutually exclusive with with_row_groups / with_row_selection: an internal state machine catches any conflicting combination in any call order and reports it as an error from build(), the legacy APIs keep their exact semantics, and each setter's docs spell out how it interacts with the others.

cc @alamb @zhuqi-lucas

@zhuqi-lucas zhuqi-lucas left a comment

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.

Thanks @haohuaijin for this work!
From the DataFusion side: root fix for apache/datafusion#24352 / apache/datafusion#24355into_builder preserving local selections is exactly it. Core looks correct and well-tested; small notes inline. Happy to take the DataFusion migration (apache/datafusion#24358) once this lands.

fields,
batch_size,
row_groups,
row_group_plan,

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.

async build threads row_group_plan through but never calls into_global() — what happens if with_row_group_selections reaches here? A one-line test pinning either "works" or "clean error" would prevent a silent misbehave.

/// ])
/// # }
/// ```
pub fn with_row_group_selections(

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.

Worth adding tests while fresh: PerRowGroup + offset/limit, a duplicate RG index (doc says "decoded once per entry"), a selection shorter than its RG (trailing-skip), and empty vec![] (currently reads nothing).

let Some(row_group_idx) = self.queued.front() else {
return Ok(None);
};
if self.budget.is_exhausted()

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.

nit: this early-exit only fires for Global; PerRowGroup drains via the selected_rows == 0 → continue path below — a short comment on that asymmetry would help.

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

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support row-group-local row selections in the Parquet push decoder

2 participants