parquet: cache per-file ArrowReaderMetadata for wide-schema scans#22830
Draft
adriangb wants to merge 1 commit into
Draft
parquet: cache per-file ArrowReaderMetadata for wide-schema scans#22830adriangb wants to merge 1 commit into
adriangb wants to merge 1 commit into
Conversation
Building an `ArrowReaderMetadata` walks every leaf of the parquet schema to produce the arrow `Schema` + dremel field levels. For wide-schema files this O(N_columns) walk runs on every file open, once per query, even though the result is identical across queries for the same file. Cache it on `CachedParquetMetaData` (which already lives in the file metadata cache): - `arrow_reader_metadata()` lazily builds the base `ArrowReaderMetadata` via `parquet_to_arrow_schema_and_field_levels` + `ArrowReaderMetadata::from_field_levels` and memoises it in a `OnceLock`; warm hits are a cheap `Arc`-bump clone. - `coerced_arrow_reader_metadata()` memoises a single post-coercion build keyed by the supplied schema's `Arc` identity (the common case: every file coerces to the same table schema). - `CachedParquetFileReader` overrides `AsyncFileReader::get_arrow_reader_metadata` to serve both from cache, falling back to a fetch + `try_new` on miss. Depends on the arrow-rs primitives in apache/arrow-rs#9882 (`from_field_levels`, `parquet_to_arrow_schema_and_field_levels`, `ArrowReaderOptions` accessors, `AsyncFileReader::get_arrow_reader_metadata`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 8, 2026
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
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?
Part of the wide-schema parquet read performance work in #21968.
Rationale for this change
Building an
ArrowReaderMetadatawalks every leaf of the parquet schemato produce the arrow
Schema+ dremel field levels. For wide-schemafiles (hundreds/thousands of columns) this
O(N_columns)walk runs onevery file open, once per query, even though the result is identical
across queries for the same file. It is one of the larger remaining
per-file costs identified in #21968.
What changes are included in this PR?
Cache the built
ArrowReaderMetadataonCachedParquetMetaData(whichalready lives in the file metadata cache):
arrow_reader_metadata()lazily builds the base metadata viaparquet_to_arrow_schema_and_field_levels+from_field_levelsandmemoises it in a
OnceLock; warm hits are a cheapArc-bump clone.coerced_arrow_reader_metadata()memoises a single post-coercionbuild keyed by the supplied schema's
Arcidentity.CachedParquetFileReaderoverridesAsyncFileReader::get_arrow_reader_metadatato serve both from cache.Status / dependencies
This depends on the arrow-rs primitives in apache/arrow-rs#9882
(
from_field_levels,parquet_to_arrow_schema_and_field_levels,ArrowReaderOptionsaccessors,AsyncFileReader::get_arrow_reader_metadata).It is not buildable yet: DataFusion
mainpins arrow58.3.0whilethose primitives are on arrow-rs
main(59.0.0), so no Cargo[patch]can satisfy
^58.3.0. CI will be red until the arrow-rs changes ship ina release DataFusion bumps to (then the
[patch]/version wiring is addedhere). Kept as a draft until then.
The arrow-rs-independent pieces of the #21968 investigation
(
memory_sizecaching, coercion early-return) are split out into aseparately-mergeable PR: #22829.
Are these changes tested?
Not yet (blocked on building, see above). Tests will be added once the
dependency is available.
Are there any user-facing changes?
No public API changes —
CachedParquetMetaDatagains internal cachingfields and methods.