-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix parquet filter_pushdown: respect parquet filter pushdown config in scan #16646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -343,9 +343,7 @@ impl ParquetSource { | |
| } | ||
|
|
||
| /// If true, the predicate will be used during the parquet scan. | ||
| /// Defaults to false | ||
| /// | ||
| /// [`Expr`]: datafusion_expr::Expr | ||
| /// Defaults to false. | ||
| pub fn with_pushdown_filters(mut self, pushdown_filters: bool) -> Self { | ||
| self.table_parquet_options.global.pushdown_filters = pushdown_filters; | ||
| self | ||
|
|
@@ -625,7 +623,13 @@ impl FileSource for ParquetSource { | |
| let Some(file_schema) = self.file_schema.clone() else { | ||
| return Ok(FilterPushdownPropagation::unsupported(filters)); | ||
| }; | ||
| // Can we push down the filters themselves into the scan or only use stats pruning? | ||
| // Determine if based on configs we should push filters down. | ||
| // If either the table / scan itself or the config has pushdown enabled, | ||
| // we will push down the filters. | ||
| // If both are disabled, we will not push down the filters. | ||
| // By default they are both disabled. | ||
| // Regardless of pushdown, we will update the predicate to include the filters | ||
| // because even if scan pushdown is disabled we can still use the filters for stats pruning. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had wondered about this; thanks for updating this comment! |
||
| let config_pushdown_enabled = config.execution.parquet.pushdown_filters; | ||
| let table_pushdown_enabled = self.pushdown_filters(); | ||
| let pushdown_filters = table_pushdown_enabled || config_pushdown_enabled; | ||
|
|
@@ -647,6 +651,7 @@ impl FileSource for ParquetSource { | |
| None => conjunction(allowed_filters.iter().cloned()), | ||
| }; | ||
| source.predicate = Some(predicate); | ||
| source = source.with_pushdown_filters(pushdown_filters); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alamb this is the relevant LOC that fixes things |
||
| let source = Arc::new(source); | ||
| // If pushdown_filters is false we tell our parents that they still have to handle the filters, | ||
| // even if we updated the predicate to include the filters (they will only be used for stats pruning). | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this result in wrong results?
Is it because the planner assumed filters would be pushed down but they weren't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this bit is just a comment 😛
But this produced wrong results because we'd return
Supported(filter)up to the parents ->FilterExecremoved from the plan butParquetOpener.pushdown_filters = false-> pruning did not actually happen during the scan.