Skip to content

Commit

Permalink
Also push down all filters in TableProvider (#5420)
Browse files Browse the repository at this point in the history
  • Loading branch information
avantgardnerio authored Feb 27, 2023
1 parent 06fecac commit c676d10
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
14 changes: 14 additions & 0 deletions datafusion/core/src/datasource/datasource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,27 @@ pub trait TableProvider: Sync + Send {

/// Tests whether the table provider can make use of a filter expression
/// to optimise data retrieval.
#[deprecated(since = "20.0.0", note = "use supports_filters_pushdown instead")]
fn supports_filter_pushdown(
&self,
_filter: &Expr,
) -> Result<TableProviderFilterPushDown> {
Ok(TableProviderFilterPushDown::Unsupported)
}

/// Tests whether the table provider can make use of any or all filter expressions
/// to optimise data retrieval.
#[allow(deprecated)]
fn supports_filters_pushdown(
&self,
filters: &[&Expr],
) -> Result<Vec<TableProviderFilterPushDown>> {
filters
.iter()
.map(|f| self.supports_filter_pushdown(f))
.collect()
}

/// Get statistics for this table, if available
fn statistics(&self) -> Option<Statistics> {
None
Expand Down
10 changes: 5 additions & 5 deletions datafusion/core/src/datasource/default_table_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ impl TableSource for DefaultTableSource {
self.table_provider.schema()
}

/// Tests whether the table provider can make use of a filter expression
/// Tests whether the table provider can make use of any or all filter expressions
/// to optimise data retrieval.
fn supports_filter_pushdown(
fn supports_filters_pushdown(
&self,
filter: &Expr,
) -> datafusion_common::Result<TableProviderFilterPushDown> {
self.table_provider.supports_filter_pushdown(filter)
filter: &[&Expr],
) -> datafusion_common::Result<Vec<TableProviderFilterPushDown>> {
self.table_provider.supports_filters_pushdown(filter)
}

fn get_logical_plan(&self) -> Option<&datafusion_expr::LogicalPlan> {
Expand Down
3 changes: 1 addition & 2 deletions datafusion/optimizer/src/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ fn coerce_scalar_range_aware(
coerce_scalar(largest_type, value).map_or_else(
|_| {
Err(DataFusionError::Execution(format!(
"Cannot cast {:?} to {:?}",
value, target_type
"Cannot cast {value:?} to {target_type:?}"
)))
},
|_| ScalarValue::try_from(target_type),
Expand Down

0 comments on commit c676d10

Please sign in to comment.