-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-28910: Remove redundant IS NOT NULL predicates when expanding SEARCH #5795
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
zabetak
wants to merge
7
commits into
apache:master
Choose a base branch
from
zabetak:unknown-ctx-search
base: master
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.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
236d522
HIVE-28910: Remove redundant IS NOT NULL predicates when expanding SE…
zabetak 9ba2e05
Review and update .q.out files
zabetak dc4a1d9
Limit simplify logic to plain conjunctions/disjunctions and document …
zabetak 320657e
Add unit tests for SearchTransformer nullability simplifications
zabetak 57ae873
Merge remote-tracking branch 'origin/master' into unknown-ctx-search
zabetak 7e8184f
Update cbo_join_transitive_pred_loop_1.q.out after merge with master
zabetak 09e051f
AssertionError due to type inference when calling RexBuilder#makeCall
zabetak 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
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
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
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
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.
Can you elaborate on why you can't use the outermost handler here?
In the Jira ticket you seem towards the opposite direction, that is taking into account that in
WHERE
clauses filters obey to theunknownAsFalse
semantics.I haven't reviewed the Calcite upgrade which introduced some of the code you touch here, so maybe it should be clear from the context.
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.
There are some operators with special semantics that we need to retain the 3-valued logic even if we are inside the
WHERE
clause.Example:
COALESCE(SEARCH(...), true)
If we consider
unknownAsFalse
inside the COALESCE then we will incorrectly drop theIS NOT NULL
predicate during the expansion and the COALESCE will fall into the third case returningtrue
instead offalse
.Basically, if the SEARCH is below/inside an operator that is sensitive to null values we cannot safely perform the simplification.
Note that
RexSimplify
also changes the default unknown semantics for certain operators (seesimplifyIs2
,simplifyCoalesce
, etc.).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.
I suspected something similar, thanks for the clarification.
Since this is a rather deep technical detail that most people not familiar with CBO will have problems with, I'd suggest to have a more explicit comment like "// These operator kinds require the UNKNOWN handler to correctly handle NULL values" or something similar.
I know it's still a draft PR but for the rest LGTM already, feel free to ping me for a review if needed.
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.
I added more comments and also made the approach a bit more defensive in the sense that if SEARCH happens to be under any operator other than AND/OR we don't perform the simplification.