Skip to content

Apache DataFusion SQL Query Engine

Update the comment and Add a check (#9571)

colommara9b0db44f313
diff --git a/datafusion/core/src/datasource/provider.rs b/datafusion/core/src/datasource/provider.rs
index e769084df6..f2e3e907e5 100644
--- a/datafusion/core/src/datasource/provider.rs
+++ b/datafusion/core/src/datasource/provider.rs
@@ -166,6 +166,7 @@ pub trait TableProvider: Sync + Send {
/// Tests whether the table provider can make use of any or all filter expressions
/// to optimise data retrieval.
+ /// Note: the returned vector much have the same size as the filters argument.
#[allow(deprecated)]
fn supports_filters_pushdown(
&self,
diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs
index a63133c516..e93e171e03 100644
--- a/datafusion/optimizer/src/push_down_filter.rs
+++ b/datafusion/optimizer/src/push_down_filter.rs
@@ -859,6 +859,13 @@ impl OptimizerRule for PushDownFilter {
let results = scan
.source
.supports_filters_pushdown(filter_predicates.as_slice())?;
+ if filter_predicates.len() != results.len() {
+ return internal_err!(
+ "Vec returned length: {} from supports_filters_pushdown is not the same size as the filters passed, which length is: {}",
+ results.len(),
+ filter_predicates.len());
+ }
+
let zip = filter_predicates.iter().zip(results);
let new_scan_filters = zip