Skip to content

Commit

Permalink
Update the comment and Add a check (apache#9571)
Browse files Browse the repository at this point in the history
* Update the comment and Add a check

Update the comment on TableProvider::supports_filters_pushdown() to say that the returned vector much have the same size as the filters argument.
Add a check at the callsite that the vec returned from supports_filters_pushdown is the same size as the filters passed:

* update after the review

* Update push_down_filter.rs
  • Loading branch information
colommar authored Mar 13, 2024
1 parent 9b6da0a commit a9b0db4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions datafusion/core/src/datasource/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions datafusion/optimizer/src/push_down_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9b0db4

Please sign in to comment.