@@ -34,7 +34,7 @@ use datafusion_physical_plan::{
34
34
35
35
use crate :: file_scan_config:: FileScanConfig ;
36
36
use datafusion_common:: config:: ConfigOptions ;
37
- use datafusion_common:: { Constraints , Statistics } ;
37
+ use datafusion_common:: { Constraints , Result , Statistics } ;
38
38
use datafusion_execution:: { SendableRecordBatchStream , TaskContext } ;
39
39
use datafusion_physical_expr:: { EquivalenceProperties , Partitioning , PhysicalExprRef } ;
40
40
use datafusion_physical_expr_common:: sort_expr:: LexOrdering ;
@@ -54,7 +54,7 @@ pub trait DataSource: Send + Sync + Debug {
54
54
& self ,
55
55
partition : usize ,
56
56
context : Arc < TaskContext > ,
57
- ) -> datafusion_common :: Result < SendableRecordBatchStream > ;
57
+ ) -> Result < SendableRecordBatchStream > ;
58
58
fn as_any ( & self ) -> & dyn Any ;
59
59
/// Format this source for display in explain plans
60
60
fn fmt_as ( & self , t : DisplayFormatType , f : & mut Formatter ) -> fmt:: Result ;
@@ -65,13 +65,13 @@ pub trait DataSource: Send + Sync + Debug {
65
65
_target_partitions : usize ,
66
66
_repartition_file_min_size : usize ,
67
67
_output_ordering : Option < LexOrdering > ,
68
- ) -> datafusion_common :: Result < Option < Arc < dyn DataSource > > > {
68
+ ) -> Result < Option < Arc < dyn DataSource > > > {
69
69
Ok ( None )
70
70
}
71
71
72
72
fn output_partitioning ( & self ) -> Partitioning ;
73
73
fn eq_properties ( & self ) -> EquivalenceProperties ;
74
- fn statistics ( & self ) -> datafusion_common :: Result < Statistics > ;
74
+ fn statistics ( & self ) -> Result < Statistics > ;
75
75
/// Return a copy of this DataSource with a new fetch limit
76
76
fn with_fetch ( & self , _limit : Option < usize > ) -> Option < Arc < dyn DataSource > > ;
77
77
fn fetch ( & self ) -> Option < usize > ;
@@ -81,15 +81,25 @@ pub trait DataSource: Send + Sync + Debug {
81
81
fn try_swapping_with_projection (
82
82
& self ,
83
83
_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
+ /// return 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::with_filter_pushdown_result`]
96
+ /// for more details.
97
+ ///
98
+ /// [`ExecutionPlan::push_down_filters`]: datafusion_physical_plan::execution_plan::ExecutionPlan::with_filter_pushdown_result
89
99
fn push_down_filters (
90
100
& self ,
91
101
_filters : & [ PhysicalExprRef ] ,
92
- ) -> datafusion_common :: Result < Option < DataSourceFilterPushdownResult > > {
102
+ ) -> Result < Option < DataSourceFilterPushdownResult > > > {
93
103
Ok ( None )
94
104
}
95
105
}
@@ -146,15 +156,15 @@ impl ExecutionPlan for DataSourceExec {
146
156
fn with_new_children (
147
157
self : Arc < Self > ,
148
158
_: Vec < Arc < dyn ExecutionPlan > > ,
149
- ) -> datafusion_common :: Result < Arc < dyn ExecutionPlan > > {
159
+ ) -> Result < Arc < dyn ExecutionPlan > > {
150
160
Ok ( self )
151
161
}
152
162
153
163
fn repartitioned (
154
164
& self ,
155
165
target_partitions : usize ,
156
166
config : & ConfigOptions ,
157
- ) -> datafusion_common :: Result < Option < Arc < dyn ExecutionPlan > > > {
167
+ ) -> Result < Option < Arc < dyn ExecutionPlan > > > {
158
168
let data_source = self . data_source . repartitioned (
159
169
target_partitions,
160
170
config. optimizer . repartition_file_min_size ,
@@ -178,15 +188,15 @@ impl ExecutionPlan for DataSourceExec {
178
188
& self ,
179
189
partition : usize ,
180
190
context : Arc < TaskContext > ,
181
- ) -> datafusion_common :: Result < SendableRecordBatchStream > {
191
+ ) -> Result < SendableRecordBatchStream > {
182
192
self . data_source . open ( partition, context)
183
193
}
184
194
185
195
fn metrics ( & self ) -> Option < MetricsSet > {
186
196
Some ( self . data_source . metrics ( ) . clone_inner ( ) )
187
197
}
188
198
189
- fn statistics ( & self ) -> datafusion_common :: Result < Statistics > {
199
+ fn statistics ( & self ) -> Result < Statistics > {
190
200
self . data_source . statistics ( )
191
201
}
192
202
@@ -204,15 +214,15 @@ impl ExecutionPlan for DataSourceExec {
204
214
fn try_swapping_with_projection (
205
215
& self ,
206
216
projection : & ProjectionExec ,
207
- ) -> datafusion_common :: Result < Option < Arc < dyn ExecutionPlan > > > {
217
+ ) -> Result < Option < Arc < dyn ExecutionPlan > > > {
208
218
self . data_source . try_swapping_with_projection ( projection)
209
219
}
210
220
211
221
fn with_filter_pushdown_result (
212
222
self : Arc < Self > ,
213
223
own_filters_result : & [ FilterSupport ] ,
214
224
parent_filters_remaining : & [ PhysicalExprRef ] ,
215
- ) -> datafusion_common :: Result < Option < ExecutionPlanFilterPushdownResult > > {
225
+ ) -> Result < Option < ExecutionPlanFilterPushdownResult > > {
216
226
// We didn't give out any filters, this should be empty!
217
227
assert ! ( own_filters_result. is_empty( ) ) ;
218
228
// Forward filter pushdown to our data source.
0 commit comments