-
Notifications
You must be signed in to change notification settings - Fork 119
fix: re-enable timestamp column for data skipping based on max values stats #1333
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
Open
sgrebnov
wants to merge
4
commits into
delta-io:main
Choose a base branch
from
spiceai:sgrebnov/timestamp-maxvalues-pruning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+45
−46
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
068be65
Re-enable file skipping on timestamp columns based on max values stats
sgrebnov 8f2e4bc
Make timestamp adjustment logic more explicit
sgrebnov dd67824
Merge branch 'main' into sgrebnov/timestamp-maxvalues-pruning
sgrebnov 0f80b97
Merge branch 'main' into sgrebnov/timestamp-maxvalues-pruning
sgrebnov 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
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
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
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.
should this always be subtracting the val?
Am I missing something here? Could you add some extra details/context in comments to serve as a proof?
Uh oh!
There was an error while loading. Please reload this page.
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.
My guess is that we're never doing a comparison
value > maxsince we only ever want to checkvalue <= max=>! (value < max).EDIT: should be
value <= max=>! (value > max).Uh oh!
There was an error while loading. Please reload this page.
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.
@OussamaSaoudi - thank you for the deep dive and review! Yeah, I was thinking about the same when working on the fix - we only do
max > valueor!(max < value), decreasingvalhelps keep more records in both cases. Please let me know if you would like me to be more specific and add match forord=Greater, inverted=falseandord=Less, inverted=trueonlyOther reasoning I used:
(max + 999) operator valthen(max + 999-999) operator val-999is valid as well so we have our current logic(max operator val-999case.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.
Good idea! Let's handle by cases.
max > valueormax >= value. Represented by: (ord=Greater, inverted=false) and (ord=Less, inverted=true)max >= value + 999, it must be the case thatmax >= valuemax < valueormax <= value. (ord=Less, inverted=false) and (ord=Greater, inverted=true)max <= value - 999, then it must be the case thatmax <= valuemax + 999 <= valueto avoid underflowThere 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.
CC @scovich Would love your eyes on this.
Uh oh!
There was an error while loading. Please reload this page.
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.
AFAIK, we only have four rewrites for inequalities:
col < val=>stats.min.col < valNOT(col < val)=>NOT(stats.max.col < val)col > val=>stats.max.col > valNOT(col > val)=>NOT(stats.min.col > val)If I understand correctly, the two involving max stats would be changed to:
col > val=>stats.max.col > val - 999NOT(col < val)=>NOT(stats.max.col < val - 999)And because this is data skipping, we only care whether the new rewrite might produce a
FALSEwhere the old rewrite did not produceFALSE. Because that corresponds to wrongly skipping a file.For the first: if
stats.max.col > val - 999is FALSE, then the max-value is "too small" andstats.max.col > valmust also return FALSE.For the second, let's simplify a bit by pushing down the NOT:
NOT(stats.max.col < val - 999)=>stats.max.col >= val - 999If
stats.max.col >= val - 999is FALSE, then the max-value is again "too small" andstats.max.col >= valmust also return FALSE.AFAICT, the rewrite is sound, because any time it returns FALSE the original predicate also returned FALSE.