Apache DataFusion SQL Query Engine
Also push down all filters in TableProvider (#5420)
Brent Gardnerc676d1026f8f
diff --git a/datafusion/core/src/datasource/datasource.rs b/datafusion/core/src/datasource/datasource.rsindex 8b0c823acf..6277ce146a 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<Vec<TableProviderFilterPushDown>> {+ filters+ .iter()+ .map(|f| self.supports_filter_pushdown(f))+ .collect()+ }+/// Get statistics for this table, if availablefn statistics(&self) -> Option<Statistics> {Nonediff --git a/datafusion/core/src/datasource/default_table_source.rs b/datafusion/core/src/datasource/default_table_source.rsindex bbb9fbdd64..c6fd87e7f1 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<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> {diff --git a/datafusion/optimizer/src/type_coercion.rs b/datafusion/optimizer/src/type_coercion.rsindex 4031edcac6..c4c5c29d37 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),