Skip to content

feat: Add expr_adapter_factory getter and with_expr_adapter_factory setter on ListingTable - #27317

Merged
alamb merged 1 commit into
apache:mainfrom
Sruhvx-jpg:feat/listing-table-expr-adapter-factory
Nov 11, 2026
Merged

alamb merged 1 commit into
apache:mainfrom
Sruhvx-jpg:feat/listing-table-expr-adapter-factory

Conversation

@Sruhvx-jpg

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #27314.

Rationale for this change

In ListingTable, swapping or wrapping the PhysicalExprAdapterFactory of an existing table currently requires manually unpacking individual fields to construct a ListingTableConfig and calling ListingTable::try_new(config). This is verbose, discards runtime table state (such as file statistics cache, table definitions, constraints, and column defaults), and redundantly re-evaluates schemas and fingerprints.

While ListingTableConfig provides with_expr_adapter_factory, ListingTable was missing the matching getter and setter after SchemaAdapterFactory was replaced by PhysicalExprAdapterFactory.

What changes are included in this PR?

  1. Added pub fn expr_adapter_factory(&self) -> Option<&Arc<dyn PhysicalExprAdapterFactory>> to ListingTable.
  2. Added pub fn with_expr_adapter_factory(mut self, expr_adapter_factory: Arc<dyn PhysicalExprAdapterFactory>) -> Self to ListingTable.
  3. Added unit test in datafusion/catalog-listing/src/table.rs verifying adapter assignment, retrieval, and replacement on cloned tables without mutating the original table.

Are these changes tested?

Yes, tested via test_with_expr_adapter_factory in datafusion-catalog-listing. Verified clean formatting (cargo fmt) and zero clippy warnings.

@github-actions github-actions Bot added the catalog Related to the catalog crate label Nov 10, 2026
@Sruhvx-jpg
Sruhvx-jpg force-pushed the feat/listing-table-expr-adapter-factory branch from 85ba53f to 96a480b Compare November 10, 2026 20:12

@alamb alamb 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.

Thanks @Sruhvx-jpg

I wonder if there are other fields we should add accessors for?

@Sruhvx-jpg

Copy link
Copy Markdown
Contributor Author

Thanks @alamb! I asked my clanker to perform a research on your concern and this is my review of the research:

  1. ListingTableConfig::expr_adapter_factory(&self):
    ListingTableConfig has with_expr_adapter_factory(...), but the field is pub(crate) with no getter. Since this PR is already touching adapter accessors, I can add it here if you want.
  2. ListingTable::file_schema(&self) -> &SchemaRef:
    table.schema() returns table_schema (file schema + partition columns), so there's currently no way to get the raw file schema directly (which caused the partition-filtering workaround in API to more easily update schema adapter factory on a ListingTable #27314).
  3. ListingTable::cache(&self) -> Option<&Arc<FileStatisticsCache>>:
    with_cache(...) exists, but there's no getter to read the cache back out.

I can open separate PRs for file_schema and cache. Should I add the ListingTableConfig::expr_adapter_factory getter to this PR, or save that for a separate PR too?

@alamb

alamb commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Yeah, let's make separate PRs please

@alamb
alamb added this pull request to the merge queue Nov 11, 2026
Merged via the queue into apache:main with commit 51960db Nov 11, 2026
44 checks passed
mbutrovich pushed a commit to gonappuccino/datafusion that referenced this pull request Nov 12, 2026
…istingTable and ListingTableConfig (apache#27363)

## Which issue does this PR close?

Follow-up to apache#27317. Closes apache#27314.

## Rationale for this change

In `ListingTable` and `ListingTableConfig`, several fields lacked
accessors:
1. `ListingTable::file_schema`: Currently `table.schema()` returns the
combined table schema (file schema + Hive partition columns). Callers
had no way to inspect or retrieve the raw physical file schema directly,
requiring manual partition-column filtering workarounds as seen in
apache#27314.
2. `ListingTable::cache`: `with_cache` setter existed, but there was no
getter to inspect or forward the attached `FileStatisticsCache`.
3. `ListingTableConfig::expr_adapter_factory`:
`with_expr_adapter_factory` setter existed, but the field was
`pub(crate)` without a public getter.

## What changes are included in this PR?

1. Added `pub fn file_schema(&self) -> &SchemaRef` to `ListingTable`.
2. Added `pub fn cache(&self) -> Option<&Arc<FileStatisticsCache>>` to
`ListingTable`.
3. Added `pub fn expr_adapter_factory(&self) -> Option<&Arc<dyn
PhysicalExprAdapterFactory>>` to `ListingTableConfig`.
4. Added unit tests for all three accessors in `table.rs` and
`config.rs`.

## Are these changes tested?

Yes, tested via unit tests in `datafusion-catalog-listing`:
- `test_file_schema`
- `test_cache`
- `test_config_expr_adapter_factory`

Verified with `cargo fmt` and `cargo clippy`.
alamb added a commit that referenced this pull request Nov 12, 2026
…er_factory setter on ListingTable (backport #27317) (#27369)

## Which issue does this PR close?

- part of #24461
- Backport of #27317 to `branch-56`
- Related to #27314.

Co-authored-by: Sruhvx <[email protected]>
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 v57.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API to more easily update schema adapter factory on a ListingTable

2 participants