Skip to content

Commit 60e3d5c

Browse files
authored
feat: Add file_schema, cache, and expr_adapter_factory accessors to ListingTable 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`.
1 parent 1a7ceda commit 60e3d5c

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎datafusion/catalog-listing/src/config.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ impl ListingTableConfig {
269269
}
270270
}
271271

272+
/// Returns the [`PhysicalExprAdapterFactory`] used by this configuration, if set.
273+
pub fn expr_adapter_factory(&self) -> Option<&Arc<dyn PhysicalExprAdapterFactory>> {
274+
self.expr_adapter_factory.as_ref()
275+
}
276+
272277
/// Set the [`PhysicalExprAdapterFactory`] for the [`crate::ListingTable`]
273278
///
274279
/// The expression adapter factory is used to create physical expression adapters that can

‎datafusion/catalog-listing/src/table.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ impl ListingTable {
302302
self
303303
}
304304

305+
/// Returns the [`FileStatisticsCache`] used to cache parquet file statistics, if set.
306+
pub fn cache(&self) -> Option<&Arc<FileStatisticsCache>> {
307+
self.collected_statistics.as_ref()
308+
}
309+
305310
/// Specify the SQL definition for this table, if any
306311
pub fn with_definition(mut self, definition: Option<String>) -> Self {
307312
self.definition = definition;
@@ -323,6 +328,11 @@ impl ListingTable {
323328
self.schema_source
324329
}
325330

331+
/// Returns the physical schema of the files, excluding partition columns.
332+
pub fn file_schema(&self) -> &SchemaRef {
333+
&self.file_schema
334+
}
335+
326336
/// Deprecated: Set the [`SchemaAdapterFactory`] for this [`ListingTable`]
327337
///
328338
/// `SchemaAdapterFactory` has been removed. Use [`ListingTableConfig::with_expr_adapter_factory`]

0 commit comments

Comments
 (0)