@@ -34,7 +34,7 @@ use datafusion_physical_plan::{
3434
3535use crate :: file_scan_config:: FileScanConfig ;
3636use datafusion_common:: config:: ConfigOptions ;
37- use datafusion_common:: { Constraints , Statistics } ;
37+ use datafusion_common:: { Constraints , Result , Statistics } ;
3838use datafusion_execution:: { SendableRecordBatchStream , TaskContext } ;
3939use datafusion_physical_expr:: { EquivalenceProperties , Partitioning , PhysicalExprRef } ;
4040use datafusion_physical_expr_common:: sort_expr:: LexOrdering ;
@@ -54,7 +54,7 @@ pub trait DataSource: Send + Sync + Debug {
5454 & self ,
5555 partition : usize ,
5656 context : Arc < TaskContext > ,
57- ) -> datafusion_common :: Result < SendableRecordBatchStream > ;
57+ ) -> Result < SendableRecordBatchStream > ;
5858 fn as_any ( & self ) -> & dyn Any ;
5959 /// Format this source for display in explain plans
6060 fn fmt_as ( & self , t : DisplayFormatType , f : & mut Formatter ) -> fmt:: Result ;
@@ -65,13 +65,13 @@ pub trait DataSource: Send + Sync + Debug {
6565 _target_partitions : usize ,
6666 _repartition_file_min_size : usize ,
6767 _output_ordering : Option < LexOrdering > ,
68- ) -> datafusion_common :: Result < Option < Arc < dyn DataSource > > > {
68+ ) -> Result < Option < Arc < dyn DataSource > > > {
6969 Ok ( None )
7070 }
7171
7272 fn output_partitioning ( & self ) -> Partitioning ;
7373 fn eq_properties ( & self ) -> EquivalenceProperties ;
74- fn statistics ( & self ) -> datafusion_common :: Result < Statistics > ;
74+ fn statistics ( & self ) -> Result < Statistics > ;
7575 /// Return a copy of this DataSource with a new fetch limit
7676 fn with_fetch ( & self , _limit : Option < usize > ) -> Option < Arc < dyn DataSource > > ;
7777 fn fetch ( & self ) -> Option < usize > ;
@@ -81,15 +81,25 @@ pub trait DataSource: Send + Sync + Debug {
8181 fn try_swapping_with_projection (
8282 & self ,
8383 _projection : & ProjectionExec ,
84- ) -> datafusion_common:: Result < Option < Arc < dyn ExecutionPlan > > > ;
85- /// Push down filters from parent execution plans to this data source.
86- /// This is expected to return Ok(None) if the filters cannot be pushed down.
87- /// If they can be pushed down it should return a [`FilterPushdownResult`] containing the new
88- /// data source and the support level for each filter (exact or inexact).
84+ ) -> Result < Option < Arc < dyn ExecutionPlan > > > ;
85+
86+ /// Push down filters into this `DataSource`.
87+ ///
88+ /// Returns `Ok(None)` if the filters cannot be evaluated within the
89+ /// `DataSource`.
90+ ///
91+ /// If the filters can be evaluated by the `DataSource`,
92+ /// sreturn a [`FilterPushdownResult`] containing an updated
93+ /// `DataSource` and the support level for each filter (exact or inexact).
94+ ///
95+ /// Default implementation returns `Ok(None)`. See [`ExecutionPlan::push_down_filters`]
96+ /// for more details.
97+ ///
98+ /// [`ExecutionPlan::push_down_filters`]: datafusion_physical_plan::execution_plan::ExecutionPlan::push_down_filters
8999 fn push_down_filters (
90100 & self ,
91101 _filters : & [ PhysicalExprRef ] ,
92- ) -> datafusion_common :: Result < Option < DataSourceFilterPushdownResult > > {
102+ ) -> Result < Option < FilterPushdownResult < Arc < dyn DataSource > > > > {
93103 Ok ( None )
94104 }
95105}
@@ -146,15 +156,15 @@ impl ExecutionPlan for DataSourceExec {
146156 fn with_new_children (
147157 self : Arc < Self > ,
148158 _: Vec < Arc < dyn ExecutionPlan > > ,
149- ) -> datafusion_common :: Result < Arc < dyn ExecutionPlan > > {
159+ ) -> Result < Arc < dyn ExecutionPlan > > {
150160 Ok ( self )
151161 }
152162
153163 fn repartitioned (
154164 & self ,
155165 target_partitions : usize ,
156166 config : & ConfigOptions ,
157- ) -> datafusion_common :: Result < Option < Arc < dyn ExecutionPlan > > > {
167+ ) -> Result < Option < Arc < dyn ExecutionPlan > > > {
158168 let data_source = self . data_source . repartitioned (
159169 target_partitions,
160170 config. optimizer . repartition_file_min_size ,
@@ -178,15 +188,15 @@ impl ExecutionPlan for DataSourceExec {
178188 & self ,
179189 partition : usize ,
180190 context : Arc < TaskContext > ,
181- ) -> datafusion_common :: Result < SendableRecordBatchStream > {
191+ ) -> Result < SendableRecordBatchStream > {
182192 self . data_source . open ( partition, context)
183193 }
184194
185195 fn metrics ( & self ) -> Option < MetricsSet > {
186196 Some ( self . data_source . metrics ( ) . clone_inner ( ) )
187197 }
188198
189- fn statistics ( & self ) -> datafusion_common :: Result < Statistics > {
199+ fn statistics ( & self ) -> Result < Statistics > {
190200 self . data_source . statistics ( )
191201 }
192202
@@ -204,15 +214,15 @@ impl ExecutionPlan for DataSourceExec {
204214 fn try_swapping_with_projection (
205215 & self ,
206216 projection : & ProjectionExec ,
207- ) -> datafusion_common :: Result < Option < Arc < dyn ExecutionPlan > > > {
217+ ) -> Result < Option < Arc < dyn ExecutionPlan > > > {
208218 self . data_source . try_swapping_with_projection ( projection)
209219 }
210220
211221 fn with_filter_pushdown_result (
212222 self : Arc < Self > ,
213223 own_filters_result : & [ FilterSupport ] ,
214224 parent_filters_remaining : & [ PhysicalExprRef ] ,
215- ) -> datafusion_common :: Result < Option < ExecutionPlanFilterPushdownResult > > {
225+ ) -> Result < Option < ExecutionPlanFilterPushdownResult > > {
216226 // We didn't give out any filters, this should be empty!
217227 assert ! ( own_filters_result. is_empty( ) ) ;
218228 // Forward filter pushdown to our data source.
0 commit comments