feat: preserve bitmap-backed RowSelection through ParquetAccessPlan - #24186
Open
haohuaijin wants to merge 4 commits into
Open
feat: preserve bitmap-backed RowSelection through ParquetAccessPlan#24186haohuaijin wants to merge 4 commits into
haohuaijin wants to merge 4 commits into
Conversation
Parquet 59 added a bitmap (BooleanBuffer) backing for RowSelection in addition to the RLE selector form. Previously ParquetAccessPlan always materialized selectors, so a caller-provided bitmap selection was converted to RLE before reaching the parquet reader, which is wasteful for fragmented selections. This change keeps bitmap-backed selections bitmap-backed end to end: * `try_new_from_overall_row_selection` splits a mask-backed selection per row group with `split_off`, which slices the BooleanBuffer instead of materializing selectors. * `into_overall_row_selection` builds a bitmap-backed overall selection when any row group selection is bitmap-backed, promoting selector-backed groups (e.g. ones page index pruning intersected). * `scan_selection` promotes the incoming selection to a bitmap when intersecting with an existing bitmap-backed selection, so the intersection is a bitwise AND and stays mask-backed. * `reverse_row_selection` slices and re-concatenates the bitmap for reverse scans, with a debug_assert guarding the row-count contract.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24186 +/- ##
==========================================
+ Coverage 81.02% 81.07% +0.04%
==========================================
Files 1105 1106 +1
Lines 380671 382067 +1396
Branches 380671 382067 +1396
==========================================
+ Hits 308436 309756 +1320
- Misses 54002 54038 +36
- Partials 18233 18273 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
haohuaijin
marked this pull request as ready for review
August 9, 2026 06:30
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?
RowSelectioninParquetAccessPlan#23883Rationale for this change
Parquet 59 added a bitmap (
BooleanBuffer) backing forRowSelectionalongside the RLE selector form. However,ParquetAccessPlanalways materialized selectors, so a caller-provided bitmap selection (via theParquetRowSelectionextension or an externalParquetAccessPlan) was converted to RLE before reaching the parquet reader. For highly fragmented selections the bitmap form is significantly cheaper to build, slice, and intersect, so it should survive the trip through the access plan.What changes are included in this PR?
ParquetAccessPlan::try_new_from_overall_row_selectionsplits a mask-backed selection per row group withRowSelection::split_off, which slices theBooleanBuffer(O(bitmap) overall) instead of materializing selectors. The selector path is unchanged.ParquetAccessPlan::into_overall_row_selectionproduces a bitmap-backed overall selection when any row group selection is bitmap-backed, promoting selector-backed groups (e.g. groups that page index pruning intersected back to selectors). When no group is bitmap-backed, the existing selector path is preserved.ParquetAccessPlan::scan_selectionpromotes the incoming selection to a bitmap when the existing selection is bitmap-backed, sinceRowSelection::intersectiononly stays mask-backed when both sides are masks; the intersection is then a bitwise AND instead of a selector merge.reverse_row_selection(reverse scans for TopK) slices the bitmap per scanned row group and re-concatenates in reverse, keeping the mask backing; adebug_assertguards the "selection covers exactly the scanned row groups" contract.row_count() + skipped_row_count(), which avoids materializing selectors from a mask just to count rows.Are these changes tested?
Yes:
try_new_from_overall_row_selection(round trip + invalid row count), mixed-backing promotion ininto_overall_row_selection, mask preservation inscan_selection, and bitmap preservation throughPreparedAccessPlan::reverse(including a fully scanned row group).external_access_plan.rs: a bitmapParquetRowSelectionspanning row groups, and a bitmap selection combined with a predicate that prunes a row group via statistics.datafusion-datasource-parquetunit tests and theparquet_integrationsuite).Are there any user-facing changes?
No API changes. Behavior change: when any per-row-group selection is bitmap-backed, the overall
RowSelectionhanded to the parquet reader is now bitmap-backed instead of selector-backed (semantically identical selection).