-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Push partition_statistics into DataSource #18233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ca9bff3
023c125
83ac1c7
75be359
a841611
f2b0b8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,7 +151,21 @@ pub trait DataSource: Send + Sync + Debug { | |
| fn scheduling_type(&self) -> SchedulingType { | ||
| SchedulingType::NonCooperative | ||
| } | ||
| fn statistics(&self) -> Result<Statistics>; | ||
|
|
||
| /// Returns statistics for a specific partition, or aggregate statistics | ||
| /// across all partitions if `partition` is `None`. | ||
| fn partition_statistics(&self, partition: Option<usize>) -> Result<Statistics>; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an API changing, I think we should make
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. I added |
||
|
|
||
| /// Returns aggregate statistics across all partitions. | ||
| /// | ||
| /// # Deprecated | ||
| /// Use [`Self::partition_statistics`] instead, which provides more fine-grained | ||
| /// control over statistics retrieval (per-partition or aggregate). | ||
| #[deprecated(since = "51.0.0", note = "Use partition_statistics instead")] | ||
| fn statistics(&self) -> Result<Statistics> { | ||
| self.partition_statistics(None) | ||
| } | ||
|
|
||
| /// Return a copy of this DataSource with a new fetch limit | ||
| fn with_fetch(&self, _limit: Option<usize>) -> Option<Arc<dyn DataSource>>; | ||
| fn fetch(&self) -> Option<usize>; | ||
|
|
@@ -285,21 +299,7 @@ impl ExecutionPlan for DataSourceExec { | |
| } | ||
|
|
||
| fn partition_statistics(&self, partition: Option<usize>) -> Result<Statistics> { | ||
| if let Some(partition) = partition { | ||
| let mut statistics = Statistics::new_unknown(&self.schema()); | ||
| if let Some(file_config) = | ||
| self.data_source.as_any().downcast_ref::<FileScanConfig>() | ||
| { | ||
| if let Some(file_group) = file_config.file_groups.get(partition) { | ||
| if let Some(stat) = file_group.file_statistics(None) { | ||
| statistics = stat.clone(); | ||
| } | ||
| } | ||
| } | ||
| Ok(statistics) | ||
| } else { | ||
| Ok(self.data_source.statistics()?) | ||
| } | ||
|
Comment on lines
-288
to
-302
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was clearly buggy: in the |
||
| self.data_source.partition_statistics(partition) | ||
| } | ||
|
|
||
| fn with_fetch(&self, limit: Option<usize>) -> Option<Arc<dyn ExecutionPlan>> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test demonstrates the bug and fails on
main