Skip to content

feat: Support lazy per-file Parquet Arrow schema derivation - #25343

Merged
sunchao merged 3 commits into
apache:mainfrom
peterxcli:feat/parquet-lazy-file-schema
Sep 16, 2026
Merged

sunchao merged 3 commits into
apache:mainfrom
peterxcli:feat/parquet-lazy-file-schema

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #25251.

Rationale for this change

Readers such as Comet need each file's physical Parquet schema to choose Arrow types for nested fields, but that schema is only available after loading the footer.

What changes are included in this PR?

Add an optional ParquetFileSchemaProvider to ParquetSource, invoked after footer loading and before Arrow schema inference. It supplies a complete file schema through Arrow's existing with_schema API while retaining the original metadata. Explicit PartitionedFile.arrow_schema takes precedence.

What is the testing strategy for this PR?

Regression tests cover differing nested layouts, ENUM/BINARY handling, cached and encrypted scans, schema precedence and validation, and serialization. Extended workspace tests and lint checks pass.

Are there any user-facing changes?

Adds ParquetSource::with_schema_provider. Sources using a provider require a custom codec for plan serialization. Default scans are unchanged.

@github-actions github-actions Bot added proto Related to proto crate datasource Changes to the datasource crate labels Sep 15, 2026
@codecov-commenter

codecov-commenter commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.10180% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.95%. Comparing base (140c7c5) to head (c73495e).

Files with missing lines Patch % Lines
datafusion/datasource-parquet/src/opener/mod.rs 99.06% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25343      +/-   ##
==========================================
+ Coverage   81.93%   81.95%   +0.01%     
==========================================
  Files        1136     1136              
  Lines      429152   429482     +330     
  Branches   429152   429482     +330     
==========================================
+ Hits       351633   351964     +331     
+ Misses      56475    56471       -4     
- Partials    21044    21047       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunchao sunchao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @peterxcli! LGTM. The hook runs at the right point for per-file schema derivation, preserves the original metadata and decryption state, and respects explicit file-schema precedence. Provider-bearing sources correctly require an extension codec for DataFusion protobuf serialization.

Reviewed at a14db51. Local validation passed all 264 Parquet datasource unit tests with encryption enabled, the protobuf serialization rejection test, and an independent 20-scan DataSourceExec oracle covering nested LIST/MAP ENUM fields, invalid-UTF8 binary data, differing file layouts, view-type coercions, projections, partition values, and virtual row numbers.

The full workspace suite and end-to-end Comet projected Variant workflow were not run locally.

@sunchao
sunchao added this pull request to the merge queue Sep 16, 2026
@peterxcli

Copy link
Copy Markdown
Member Author

@sunchao thanks!

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 16, 2026
@sunchao
sunchao added this pull request to the merge queue Sep 16, 2026
Merged via the queue into apache:main with commit e3163d4 Sep 16, 2026
41 checks passed
@peterxcli
peterxcli deleted the feat/parquet-lazy-file-schema branch September 20, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

datasource Changes to the datasource crate proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow deriving a Parquet file Arrow schema from metadata during lazy opening

3 participants