forked from apache/datafusion
-
Notifications
You must be signed in to change notification settings - Fork 2
Improve doc comments of filter-pushdown-apis
#22
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
Merged
adriangb
merged 2 commits into
pydantic:filter-pushdown-apis
from
alamb:alamb/filter_pushdown_suggestions
Apr 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ use datafusion_physical_plan::{ | |
|
|
||
| use crate::file_scan_config::FileScanConfig; | ||
| use datafusion_common::config::ConfigOptions; | ||
| use datafusion_common::{Constraints, Statistics}; | ||
| use datafusion_common::{Constraints, Result, Statistics}; | ||
| use datafusion_execution::{SendableRecordBatchStream, TaskContext}; | ||
| use datafusion_physical_expr::{EquivalenceProperties, Partitioning, PhysicalExprRef}; | ||
| use datafusion_physical_expr_common::sort_expr::LexOrdering; | ||
|
|
@@ -54,7 +54,7 @@ pub trait DataSource: Send + Sync + Debug { | |
| &self, | ||
| partition: usize, | ||
| context: Arc<TaskContext>, | ||
| ) -> datafusion_common::Result<SendableRecordBatchStream>; | ||
| ) -> Result<SendableRecordBatchStream>; | ||
| fn as_any(&self) -> &dyn Any; | ||
| /// Format this source for display in explain plans | ||
| fn fmt_as(&self, t: DisplayFormatType, f: &mut Formatter) -> fmt::Result; | ||
|
|
@@ -65,13 +65,13 @@ pub trait DataSource: Send + Sync + Debug { | |
| _target_partitions: usize, | ||
| _repartition_file_min_size: usize, | ||
| _output_ordering: Option<LexOrdering>, | ||
| ) -> datafusion_common::Result<Option<Arc<dyn DataSource>>> { | ||
| ) -> Result<Option<Arc<dyn DataSource>>> { | ||
| Ok(None) | ||
| } | ||
|
|
||
| fn output_partitioning(&self) -> Partitioning; | ||
| fn eq_properties(&self) -> EquivalenceProperties; | ||
| fn statistics(&self) -> datafusion_common::Result<Statistics>; | ||
| fn statistics(&self) -> Result<Statistics>; | ||
| /// 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>; | ||
|
|
@@ -81,15 +81,25 @@ pub trait DataSource: Send + Sync + Debug { | |
| fn try_swapping_with_projection( | ||
| &self, | ||
| _projection: &ProjectionExec, | ||
| ) -> datafusion_common::Result<Option<Arc<dyn ExecutionPlan>>>; | ||
| /// Push down filters from parent execution plans to this data source. | ||
| /// This is expected to return Ok(None) if the filters cannot be pushed down. | ||
| /// If they can be pushed down it should return a [`FilterPushdownResult`] containing the new | ||
| /// data source and the support level for each filter (exact or inexact). | ||
| ) -> Result<Option<Arc<dyn ExecutionPlan>>>; | ||
|
|
||
| /// Push down filters into this `DataSource`. | ||
| /// | ||
| /// Returns `Ok(None)` if the filters cannot be evaluated within the | ||
| /// `DataSource`. | ||
| /// | ||
| /// If the filters can be evaluated by the `DataSource`, | ||
| /// sreturn a [`FilterPushdownResult`] containing an updated | ||
| /// `DataSource` and the support level for each filter (exact or inexact). | ||
| /// | ||
| /// Default implementation returns `Ok(None)`. See [`ExecutionPlan::with_filter_pushdown_result`] | ||
| /// for more details. | ||
| /// | ||
| /// [`ExecutionPlan::push_down_filters`]: datafusion_physical_plan::execution_plan::ExecutionPlan::with_filter_pushdown_result | ||
|
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. Thanks will use this style of reference elswhere |
||
| fn push_down_filters( | ||
| &self, | ||
| _filters: &[PhysicalExprRef], | ||
| ) -> datafusion_common::Result<Option<DataSourceFilterPushdownResult>> { | ||
| ) -> Result<Option<FilterPushdownResult<Arc<dyn DataSource>>>> { | ||
adriangb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Ok(None) | ||
| } | ||
| } | ||
|
|
@@ -146,15 +156,15 @@ impl ExecutionPlan for DataSourceExec { | |
| fn with_new_children( | ||
| self: Arc<Self>, | ||
| _: Vec<Arc<dyn ExecutionPlan>>, | ||
| ) -> datafusion_common::Result<Arc<dyn ExecutionPlan>> { | ||
| ) -> Result<Arc<dyn ExecutionPlan>> { | ||
| Ok(self) | ||
| } | ||
|
|
||
| fn repartitioned( | ||
| &self, | ||
| target_partitions: usize, | ||
| config: &ConfigOptions, | ||
| ) -> datafusion_common::Result<Option<Arc<dyn ExecutionPlan>>> { | ||
| ) -> Result<Option<Arc<dyn ExecutionPlan>>> { | ||
| let data_source = self.data_source.repartitioned( | ||
| target_partitions, | ||
| config.optimizer.repartition_file_min_size, | ||
|
|
@@ -178,15 +188,15 @@ impl ExecutionPlan for DataSourceExec { | |
| &self, | ||
| partition: usize, | ||
| context: Arc<TaskContext>, | ||
| ) -> datafusion_common::Result<SendableRecordBatchStream> { | ||
| ) -> Result<SendableRecordBatchStream> { | ||
| self.data_source.open(partition, context) | ||
| } | ||
|
|
||
| fn metrics(&self) -> Option<MetricsSet> { | ||
| Some(self.data_source.metrics().clone_inner()) | ||
| } | ||
|
|
||
| fn statistics(&self) -> datafusion_common::Result<Statistics> { | ||
| fn statistics(&self) -> Result<Statistics> { | ||
| self.data_source.statistics() | ||
| } | ||
|
|
||
|
|
@@ -204,15 +214,15 @@ impl ExecutionPlan for DataSourceExec { | |
| fn try_swapping_with_projection( | ||
| &self, | ||
| projection: &ProjectionExec, | ||
| ) -> datafusion_common::Result<Option<Arc<dyn ExecutionPlan>>> { | ||
| ) -> Result<Option<Arc<dyn ExecutionPlan>>> { | ||
| self.data_source.try_swapping_with_projection(projection) | ||
| } | ||
|
|
||
| fn with_filter_pushdown_result( | ||
| self: Arc<Self>, | ||
| own_filters_result: &[FilterSupport], | ||
| parent_filters_remaining: &[PhysicalExprRef], | ||
| ) -> datafusion_common::Result<Option<ExecutionPlanFilterPushdownResult>> { | ||
| ) -> Result<Option<ExecutionPlanFilterPushdownResult>> { | ||
| // We didn't give out any filters, this should be empty! | ||
| assert!(own_filters_result.is_empty()); | ||
| // Forward filter pushdown to our data source. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.