Skip to content

refactor: use inherent is::<T>() on dyn TableProvider/dyn ExecutionPlan for type checks - #11585

Merged
Jeadie merged 3 commits into
trunkfrom
jeadie/26-07-03/tableprovider-is
Jul 9, 2026
Merged

Jeadie merged 3 commits into
trunkfrom
jeadie/26-07-03/tableprovider-is

Conversation

@Jeadie

@Jeadie Jeadie commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

DataFusion 54 (apache/datafusion#21346) made Any a supertrait of TableProvider (and ExecutionPlan), adding inherent is::<T>() and downcast_ref::<T>() methods on the trait objects.

I thought we might be able to use these to improve recursive downcasting that is often buggy and brittle (e.g. search::util::find_concrete_table_provider or search::util::find_index_in_table_provider), but was not able. Instead I found and replaced x.downcast_ref::<T>().is_some() / .is_none() chains with x.is::<T>() / !x.is::<T>().

… for type checks

DataFusion 54 (apache/datafusion#21346) makes `Any` a supertrait of
`TableProvider`/`ExecutionPlan` and adds inherent `is::<T>()` /
`downcast_ref::<T>()` on the trait objects. Replace
`downcast_ref::<T>().is_some()" / ".is_none()` chains with `is::<T>()`
wherever the receiver is one of those two trait objects.

No behavior change; several multi-line wrapper-allowlist conditions in the
cayenne optimizer collapse to one line per type check.
Copilot AI review requested due to automatic review settings July 3, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors internal type checks across the query planning/optimization and distributed codec codepaths to use DataFusion 54’s inherent is::<T>() on dyn TableProvider / dyn ExecutionPlan, replacing verbose downcast_ref::<T>().is_some()/is_none() chains with clearer boolean predicates (no intended behavior change).

Changes:

  • Replace downcast_ref::<T>().is_some() with is::<T>() for ExecutionPlan/TableProvider trait objects.
  • Replace downcast_ref::<T>().is_none() chains with !is::<T>(), notably simplifying Cayenne optimizer wrapper allowlist checks.
  • Apply the same readability refactor in related tests and distributed plan/table-provider codec logic.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/vortex/src/persistent/metrics.rs Simplifies ExecutionPlanVisitor node-type detection using plan.is::<DataSourceExec>().
crates/runtime/tests/cayenne/mod.rs Uses is::<AcceleratedTable>() for asserting provider wrapper type in integration test.
crates/runtime/src/datafusion/planner/mod.rs Updates wrapper-peeling tests to assert provider type via is::<MemTable>().
crates/runtime/src/datafusion/mod.rs Updates accelerated-provider resolution test to assert MemTable via is::<MemTable>().
crates/runtime/src/datafusion/builder.rs Simplifies Cayenne table-provider detection with provider.is::<CayenneTableProvider>().
crates/runtime/src/dataconnector/iceberg_cluster.rs Uses plan.is::<IcebergTableScan>() before wrapping for distributed planning.
crates/runtime/src/cluster/datafusion/codec/spice_physical_codec.rs Uses is::<...>() for physical plan node encoding decisions where applicable.
crates/runtime/src/cluster/datafusion/codec/spice_logical_codec.rs Uses is::<ListUDFTable>() when encoding UDTF-produced TableProviders.
crates/runtime/src/accelerated_table/refresh_task.rs Updates test assertion to is::<MetadataEnrichedTableProvider>() on underlying provider.
crates/runtime-datafusion/src/extension/bytes_processed.rs Uses is::<BytesProcessedExec>() in physical optimizer early-exit condition.
crates/datafusion-optimizer-rules/src/physical_plan/http_subquery_pushdown.rs Uses is::<HttpExec>() and updates related test assertions.
crates/datafusion-optimizer-rules/src/physical_plan/flightsql/broadcast_join.rs Collapses multi-is_none() wrapper walk conditions into !is::<...>() checks.
crates/datafusion-optimizer-rules/src/physical_plan/flightsql/aggregate_pushdown.rs Uses is::<...>() when walking/identifying wrapper nodes and test plan types.
crates/cayenne/src/provider/scan.rs Simplifies wrapper allowlist/type recognition with is::<...>().
crates/cayenne/src/optimizer_rules.rs Rewrites long wrapper-allowlist is_none() chains into readable !plan.is::<...>() predicates and updates test assertions.

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Pull with Spice Passed

Passing checks:

  • ✅ Title meets minimum length requirement (10 characters)
  • ✅ No banned labels detected
  • ✅ Has a label from required category kind/
  • ✅ Has a label from required category area/
  • ✅ Has at least one assignee: Jeadie

@Jeadie
Jeadie marked this pull request as ready for review July 6, 2026 23:44
@Jeadie
Jeadie requested a review from a team as a code owner July 6, 2026 23:44
Copilot AI review requested due to automatic review settings July 7, 2026 03:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@Jeadie Jeadie self-assigned this Jul 9, 2026
@Jeadie
Jeadie enabled auto-merge July 9, 2026 00:18
@Jeadie
Jeadie added this pull request to the merge queue Jul 9, 2026
Merged via the queue into trunk with commit dc849ae Jul 9, 2026
21 of 43 checks passed
@Jeadie
Jeadie deleted the jeadie/26-07-03/tableprovider-is branch July 9, 2026 05:23
github-actions Bot pushed a commit that referenced this pull request Jul 13, 2026
…ionPlan` for type checks (#11585)

* refactor: use inherent `is::<T>()` on dyn TableProvider/ExecutionPlan for type checks

DataFusion 54 (apache/datafusion#21346) makes `Any` a supertrait of
`TableProvider`/`ExecutionPlan` and adds inherent `is::<T>()` /
`downcast_ref::<T>()` on the trait objects. Replace
`downcast_ref::<T>().is_some()" / ".is_none()` chains with `is::<T>()`
wherever the receiver is one of those two trait objects.

No behavior change; several multi-line wrapper-allowlist conditions in the
cayenne optimizer collapse to one line per type check.

* fix formatting

---------

Co-authored-by: Jeadie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants