Repository navigation
Description
Describe the bug
ParquetRecordBatchReader::try_new_with_row_groups regressed in 57.1.0 and is still broken on main: it can no longer be used with a RowGroups that holds only the data pages its RowSelection touches. Before 57.1.0 the reader had a single selection strategy, which skips absent pages correctly via skip_records(). #8733 added the Mask strategy and made Auto the default — together with a guard that keeps Mask away from page-pruned data — but the guard was only wired into the push decoder. This constructor silently began resolving to a strategy its callers' data cannot satisfy, and has no way to opt out.
Mechanically, it builds its plan as
let read_plan = ReadPlanBuilder::new(batch_size).with_selection(selection).build();so it inherits RowSelectionPolicy::default() (Auto) and never sets loaded row ranges. For a fragmented selection Auto resolves to Mask, and MaskCursor::next_chunk takes the unguarded path (if self.loaded_row_ranges.is_none()), where next_mask_chunk_non_empty advances until selected_rows == batch_size with no page awareness. The chunk therefore crosses whole skipped pages, and read_mask_batch decodes them.
The built-in readers are fine because RowGroupReaderBuilder calls prepare_selection_for_page_skipping, but that isn't reachable from this constructor: RowSelectionPolicy can't be passed, LoadedRowRanges and row_ranges_for_selected_pages are pub(crate), and ParquetRecordBatchReader::new is pub(crate).
Note: this seems to be a similar failure that #9301 fixed for the adaptive predicate pushdown path in 58.0.0 — identical error, different entry point. The guard added there lives in the push decoder, which this constructor does not go through.
To Reproduce
Create a parquet with one row group, 1000 rows, 5 data pages of 200 rows, page index present, batch_size = 200. The selection is many one-row runs inside pages 0 and 3, with pages 1, 2 and 4 skipped whole — so Auto resolves to Mask (1000 < 402 * 32; note skips count toward both sides) while only 2 of the 5 pages are fetched, via RowSelection::scan_ranges. Reading that through try_new_with_row_groups gives:
Parquet error: Invalid offset in sparse column chunk data: 8243, no matching page found.
Reading the same selection through ParquetRecordBatchReaderBuilder succeeds. Versions ≤ 57.0.x are unaffected (no Mask strategy).
Expected behavior
No error. try_new_with_row_groups should read a page-pruned RowGroups the way it did before 57.1.0 and return exactly the selected rows — the same rows ParquetRecordBatchReaderBuilder returns for the same RowSelection.
Possible fix
- Add an
offset_indexmethod on theRowGroupstrait, so it can be combined with theRowSelectionto work out which row ranges have their pages in memory, and confine mask decoding to those ranges. -> Tentative fix on fix(parquet): keep mask execution off pages a RowGroups did not load #10649 - Change the
try_new_with_row_groupsto useRowSelectionPolicy::Selectorsor accept aRowSelectionPolicyargument, so the caller can passSelectors.
The smallest possible change and it removes the error, but it forfeits mask
execution for every page-pruning caller, and it only helps callers who know they
have to ask for it — the default stays wrong. - Accept
LoadedRowRanges, i.e. export the type and makewith_loaded_row_rangespublic. Keeps mask execution, but the caller then has to build the ranges, which means exposing the derivation as well (RowSelection::loaded_row_ranges) — more public surface than the trait method forthe same result.
Activity
alamb commentedon Aug 25, 2026
@alanprot can you help me understand what the bug is from your perspective? Like what are you trying to do with this API and what is not working? The description above talks alot about the details of what the code is doing, but I don't fully understand what you are trying to do
meet987654 commentedon Nov 30, 2026
This still reproduces on main (5e2595e): the test from #10649, adapted to the current InMemoryRowGroup API (page_index: Some(metadata.page_index_for_row_group(0))), fails with Invalid offset in sparse column chunk data: 8243, no matching page found.
@alanprot, #10649 was closed by the stale bot. Do you plan to pick it up again? If not, I'd be happy to work on it. Two possible fixes:
@alamb, do you have a preference?