Repository navigation
Rewrite NOT in row filters before the Arrow scan - #4350
Open
rahulsmahadev wants to merge 1 commit into
Open
rahulsmahadev wants to merge 1 commit into
rahulsmahadev wants to merge 1 commit into
Conversation
The manifest and metrics evaluators apply rewrite_not, so not x < 6.0 decides which files are read as x >= 6.0, but the rows were filtered with ~(x < 6.0), which is true for NaN. Apply rewrite_not to the bound file filter as well, so a NaN row no longer depends on whether its file was read. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
The manifest and metrics evaluators apply
rewrite_not, sonot value < 6.0decides which files are read asvalue >= 6.0. The rows of those files were then filtered with the original expression, which Arrow evaluates as~(value < 6.0). The two disagree on NaN:value >= 6.0is false for NaN,~(value < 6.0)is true. A NaN row was therefore returned only when another value in its file kept the file from being skipped:This change applies
rewrite_notto the bound file filter in_task_to_record_batchestoo, so rows are filtered with the same predicates that decided which files to read, and NOT no longer reaches Arrow. Only negated range comparisons on NaN change: the other negations (=,IN,IS NULL,IS NaN,STARTS WITH) give the same Arrow result before and after the rewrite.Follow-up from the review of #4346, as suggested by @Fokko.
Are these changes tested?
Yes.
test_scan_negated_comparison_matches_file_pruning_for_nanintests/catalog/test_catalog_behaviors.pyscans a file that is read and a file that is skipped, both holding a NaN row, withnot value < 6.0,not (value < 6.0 and id = 1)and their rewritten forms, on each catalog of thecatalogfixture. It fails without this change.Are there any user-facing changes?
Yes: a scan whose filter negates a range comparison on a float or double column no longer returns NaN rows, which matches the file-level filtering. No API changes.
This pull request and its description were written by Isaac.