Skip to content

remove as_any from TableProvider, SchemaProvider, CatalogProvider, and CatalogProviderList#21346

Open
timsaucer wants to merge 6 commits intoapache:mainfrom
timsaucer:chore/remove-as-any-table-provider
Open

remove as_any from TableProvider, SchemaProvider, CatalogProvider, and CatalogProviderList#21346
timsaucer wants to merge 6 commits intoapache:mainfrom
timsaucer:chore/remove-as-any-table-provider

Conversation

@timsaucer
Copy link
Copy Markdown
Member

@timsaucer timsaucer commented Apr 3, 2026

Which issue does this PR close?

This is a follow on to #20812 #21209 #21263 but treats TableProvider, SchemaProvider, CatalogProvider, and CatalogProviderList.

Rationale for this change

This PR reduces the amount of boilerplate code that users need to write for catalogs through table providers.

What changes are included in this PR?

Now that we have trait upcasting since rust 1.86, we no longer need every implementation of these functions to have the as_any function that returns &self. This PR makes Any an supertrait and makes the appropriate casts when necessary.

Are these changes tested?

Existing unit tests.

Are there any user-facing changes?

Yes, the users simply need to remove the as_any function. The upgrade guide is updated.

Now that Any is a supertrait of TableProvider via trait upcasting
(Rust 1.86+), the as_any boilerplate is no longer needed. This adds
is() and downcast_ref() helper methods on dyn TableProvider and
removes as_any from the trait and all implementations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added documentation Improvements or additions to documentation core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) catalog Related to the catalog crate proto Related to proto crate functions Changes to functions implementation ffi Changes to the ffi crate labels Apr 3, 2026
timsaucer and others added 2 commits April 3, 2026 10:10
TableProvider already requires Send as a supertrait, so the explicit
+ Send is unnecessary and prevented using the new downcast_ref method
directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@timsaucer timsaucer marked this pull request as ready for review April 3, 2026 16:38
timsaucer and others added 3 commits April 3, 2026 12:52
Now that Any is a supertrait of SchemaProvider via trait upcasting
(Rust 1.86+), the as_any boilerplate is no longer needed. This adds
is() and downcast_ref() helper methods on dyn SchemaProvider and
removes as_any from the trait and all implementations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Now that Any is a supertrait of CatalogProvider via trait upcasting
(Rust 1.86+), the as_any boilerplate is no longer needed. This adds
is() and downcast_ref() helper methods on dyn CatalogProvider and
removes as_any from the trait and all implementations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Now that Any is a supertrait of CatalogProviderList via trait upcasting
(Rust 1.86+), the as_any boilerplate is no longer needed. This adds
is() and downcast_ref() helper methods on dyn CatalogProviderList and
removes as_any from the trait and all implementations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@timsaucer timsaucer changed the title remove as_any from TableProvider remove as_any from TableProvider, SchemaProvider, CatalogProvider, and CatalogProviderList Apr 3, 2026
unsafe impl Sync for FFI_CatalogProvider {}

struct ProviderPrivateData {
provider: Arc<dyn CatalogProvider + Send>,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

CatalogProvider is already Send so this is unnecessary

unsafe impl Sync for FFI_CatalogProviderList {}

struct ProviderPrivateData {
provider: Arc<dyn CatalogProviderList + Send>,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

CatalogProviderList is already Send so this is unnecessary

unsafe impl Sync for FFI_SchemaProvider {}

struct ProviderPrivateData {
provider: Arc<dyn SchemaProvider + Send>,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SchemaProvider is already Send so this is unnecessary

unsafe impl Sync for FFI_TableProvider {}

struct ProviderPrivateData {
provider: Arc<dyn TableProvider + Send>,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TableProvider is already Send so this is unnecessary

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

Labels

catalog Related to the catalog crate core Core DataFusion crate documentation Improvements or additions to documentation ffi Changes to the ffi crate functions Changes to functions implementation proto Related to proto crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant