Uh oh!
There was an error while loading. Please reload this page.
Move statistics handling into FileScanConfig - #18721
Conversation
b84171f to
e2d7126Comparee2d7126 to
5ebc343Compare| pub fn statistics(&self) -> Statistics { | ||
| if self.file_source.filter().is_some() { | ||
| self.statistics.clone().to_inexact() | ||
| } else { | ||
| self.statistics.clone() | ||
| } | ||
| } |
There was a problem hiding this comment.
Now we don't have to rely on each FileSource to remember to do this 😄
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
317486b to
c672a73Compare2dbfd1e to
ccb4e69Comparea9c8746 to
0ad47a0Compare
leoyvens
left a comment
There was a problem hiding this comment.
I'm not a maintainer, but LGTM
0ad47a0 to
dc3e9dbCompare| } | ||
| } | ||
| pub fn projected_stats(&self) -> Statistics { |
There was a problem hiding this comment.
I think this is a (small) public API change, so we should flag this PR thusly (I did) and add a note to the upgrade guide
| pub expr_adapter_factory: Option<Arc<dyn PhysicalExprAdapterFactory>>, | ||
| /// Unprojected statistics for the table (file schema + partition columns). | ||
| /// These are projected on-demand via `projected_stats()`. | ||
| pub(crate) statistics: Statistics, |
There was a problem hiding this comment.
nit is that this field has a different visibility (pub(crate)) than all the other fields
| write!( | ||
| f, | ||
| "statistics={:?}, ", | ||
| self.file_source.statistics().unwrap() |
There was a problem hiding this comment.
removing an unwrap in the display certainly seems like an improvement to me
Uh oh!
There was an error while loading. Please reload this page.
## Summary This PR moves statistics handling from individual `FileSource` implementations into `FileScanConfig`, simplifying the `FileSource` trait interface. The `FileSource`s were all acting as a container for the statistics but never actually using them. Since `FileScanConfig` deals with file-level things (which the statistics are) it is better equipped to deal with it. ### Changes - **FileSource trait simplification**: Removed `statistics()`, `with_statistics()`, and `with_projection()` methods - **FileScanConfig enhancement**: Added `statistics` field and `statistics()` method - **FileSource implementations updated**: Removed `projected_statistics` field from all implementations: - ParquetSource - CsvSource - JsonSource - AvroSource - ArrowFileSource and ArrowStreamFileSource - MockSource (test utility) - **Test utilities**: Updated assertions to use `config.statistics()` instead of `file_source.statistics()` - **Proto serialization**: Updated to use `config.statistics()` ### Benefits 1. **Simpler trait interface**: `FileSource` implementations no longer need to manage statistics 2. **Centralized statistics**: All statistics are now managed consistently in `FileScanConfig` 3. **Cleaner API**: Statistics lifecycle is clearer and less error-prone 4. **Reduced code duplication**: Removes ~140 lines of boilerplate across implementations ### Related This is part of the projection refactoring work in apache#18627. This PR extracts just the statistics-related changes to make review easier. The full projection refactoring will come in subsequent PRs. ## Test plan - [x] All modified file source implementations compile - [x] Test utilities updated and compile - [x] CI tests pass (will verify after PR creation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Summary
This PR moves statistics handling from individual
FileSourceimplementations intoFileScanConfig, simplifying theFileSourcetrait interface.The
FileSources were all acting as a container for the statistics but never actually using them.Since
FileScanConfigdeals with file-level things (which the statistics are) it is better equipped to deal with it.Changes
statistics(),with_statistics(), andwith_projection()methodsstatisticsfield andstatistics()methodprojected_statisticsfield from all implementations:config.statistics()instead offile_source.statistics()config.statistics()Benefits
FileSourceimplementations no longer need to manage statisticsFileScanConfigRelated
This is part of the projection refactoring work in #18627. This PR extracts just the statistics-related changes to make review easier. The full projection refactoring will come in subsequent PRs.
Test plan
🤖 Generated with Claude Code