From c676d1026f8fa25c1495ec139b8a379ce1f2f86b Mon Sep 17 00:00:00 2001 From: Brent Gardner Date: Mon, 27 Feb 2023 10:06:19 -0700 Subject: [PATCH] Also push down all filters in TableProvider (#5420) --- datafusion/core/src/datasource/datasource.rs | 14 ++++++++++++++ .../core/src/datasource/default_table_source.rs | 10 +++++----- datafusion/optimizer/src/type_coercion.rs | 3 +-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/datafusion/core/src/datasource/datasource.rs b/datafusion/core/src/datasource/datasource.rs index 8b0c823acf65..6277ce146adf 100644 --- a/datafusion/core/src/datasource/datasource.rs +++ b/datafusion/core/src/datasource/datasource.rs @@ -72,6 +72,7 @@ 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, @@ -79,6 +80,19 @@ pub trait TableProvider: Sync + Send { 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> { + filters + .iter() + .map(|f| self.supports_filter_pushdown(f)) + .collect() + } + /// Get statistics for this table, if available fn statistics(&self) -> Option { None diff --git a/datafusion/core/src/datasource/default_table_source.rs b/datafusion/core/src/datasource/default_table_source.rs index bbb9fbdd6492..c6fd87e7f18b 100644 --- a/datafusion/core/src/datasource/default_table_source.rs +++ b/datafusion/core/src/datasource/default_table_source.rs @@ -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 { - self.table_provider.supports_filter_pushdown(filter) + filter: &[&Expr], + ) -> datafusion_common::Result> { + self.table_provider.supports_filters_pushdown(filter) } fn get_logical_plan(&self) -> Option<&datafusion_expr::LogicalPlan> { diff --git a/datafusion/optimizer/src/type_coercion.rs b/datafusion/optimizer/src/type_coercion.rs index 4031edcac6ca..c4c5c29d37a1 100644 --- a/datafusion/optimizer/src/type_coercion.rs +++ b/datafusion/optimizer/src/type_coercion.rs @@ -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),