Skip to content

feat: allow downcasting ParquetFileReaderFactory - #26635

Open
morristai wants to merge 1 commit into
apache:mainfrom
morristai:parquet-reader-factory-downcast
Open

morristai wants to merge 1 commit into
apache:mainfrom
morristai:parquet-reader-factory-downcast

Conversation

@morristai

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

There is no way to tell which reader factory a ParquetSource uses. parquet_file_reader_factory() returns &Arc<dyn ParquetFileReaderFactory>, and the trait has no downcast path.

What changes are included in this PR?

ParquetFileReaderFactory gets Any as a supertrait, and dyn ParquetFileReaderFactory gets is and downcast_ref, like dyn FileSource in #21576. I also added a 56.0.0 upgrade guide entry, like the ones for MemoryPool (#21803) and QueryPlanner (#22241).

What is the testing strategy for this PR?

A unit test in source.rs sets each built-in factory on a ParquetSource and checks that parquet_file_reader_factory() downcasts to it.

Are there any user-facing changes?

Two new methods on dyn ParquetFileReaderFactory. The semver check will flag the new supertrait, but the trait already required 'static, so existing implementations compile unchanged.

Drafted with Claude. I reviewed the change and this text.

🤖 Generated with Claude Code

Add an `Any` supertrait to `ParquetFileReaderFactory` and the `is` and
`downcast_ref` methods that `dyn FileSource` has, so code that inspects
a `ParquetSource` can tell `DefaultParquetFileReaderFactory` and
`CachedParquetFileReaderFactory` from a caller-provided factory.

The trait already required `'static`, which `Any` implies, so existing
implementations compile unchanged; the explicit `'static` is dropped to
match the other `Any` supertraits. The 56.0.0 upgrade guide notes the
new supertrait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation datasource Changes to the datasource crate labels Oct 23, 2026
@github-actions

Copy link
Copy Markdown

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
     Cloning apache/main
    Building datafusion-datasource-parquet v55.1.0 (current)
       Built [  40.268s] (current)
     Parsing datafusion-datasource-parquet v55.1.0 (current)
      Parsed [   0.027s] (current)
    Building datafusion-datasource-parquet v55.1.0 (baseline)
       Built [  41.001s] (baseline)
     Parsing datafusion-datasource-parquet v55.1.0 (baseline)
      Parsed [   0.029s] (baseline)
    Checking datafusion-datasource-parquet v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.212s] 229 checks: 228 pass, 1 fail, 0 warn, 31 skip

--- failure trait_added_supertrait: non-sealed trait added new supertraits ---

Description:
A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#generic-bounds-tighten
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/trait_added_supertrait.ron

Failed in:
  trait datafusion_datasource_parquet::ParquetFileReaderFactory gained Any in file /home/runner/work/datafusion/datafusion/datafusion/datasource-parquet/src/reader.rs:71

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  83.427s] datafusion-datasource-parquet

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change datasource Changes to the datasource crate documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow downcasting ParquetFileReaderFactory like FileSource and DataSource

1 participant