Skip to content

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

Description

@peterxcli

Is your feature request related to a problem or challenge?

Comet's projected Variant scans need to infer each file's Arrow schema from its physical Parquet schema, ignore advisory ARROW:schema, and map ENUM leaves to Utf8 while retaining raw BINARY. The shredded layout can differ between files and is only available after loading that file's footer.

#22360 already supports an explicit PartitionedFile.arrow_schema. That solves this when the complete physical file schema is known before opening. Arrow's ArrowReaderOptions::with_schema also supports nested Binary-to-Utf8 hints, so a new Arrow ENUM conversion API is unnecessary for this case.

The remaining gap is configuring that schema during lazy file opening. On DataFusion 9082d6b10c29b72d56bede3d8e353d9d61fde542, the opener creates options from the already populated PartitionedFile, then calls ArrowReaderMetadata::load_async. ParquetFileReaderFactory returns an AsyncFileReader, whose get_metadata receives borrowed options and returns ParquetMetaData; it cannot return a newly derived Arrow schema or revised reader options to the opener.

Comet currently rewrites the returned footer's Arrow schema hint. Rebuilding public FileMetaData cannot retain its private decryptor state, so this path requires an encrypted Variant fallback.

Describe the solution you'd like

Allow a ParquetSource reader policy to derive a supplied Arrow schema from the loaded physical SchemaDescriptor during file opening, before advisory Arrow schema parsing and filter/schema preparation. Reuse Arrow's existing with_schema support and the original Arc<ParquetMetaData>, preserving decryption properties, page indexes and existing metadata-cache behavior.

The policy must be optional per source, leave ordinary scans unchanged, and support files with different nested schemas without fetching their footers during planning. A specific trait or callback design is not prescribed here.

Describe alternatives you've considered

Additional context

Tracked in apache/datafusion-comet#5477, implemented as a workaround in apache/datafusion-comet#5868. This requests a reader integration point, not a change to DataFusion's default ENUM interpretation or an expansion of the canonical Variant format.

A local check against arrow-rs 4cd8be954f6bc6b6dd265140207365b59a9900ec passed a supplied schema for nested { e: ENUM, b: BINARY }: e became Utf8, b stayed Binary, an invalid advisory ARROW:schema was ignored, and Arc::ptr_eq(reader_metadata.metadata(), original_metadata) remained true. No encrypted scan was run; preserving decryption behavior needs coverage when implementing this integration.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions