RowExpression duplicate isNull on same variable issue#16336
Merged
zhenxiao merged 1 commit intoprestodb:masterfrom Jul 2, 2021
Merged
RowExpression duplicate isNull on same variable issue#16336zhenxiao merged 1 commit intoprestodb:masterfrom
zhenxiao merged 1 commit intoprestodb:masterfrom
Conversation
e382e0b to
7d13b8e
Compare
Contributor
Author
|
cc @vkorukanti @zhenxiao any thoughts? |
zhenxiao
reviewed
Jun 29, 2021
Collaborator
zhenxiao
left a comment
There was a problem hiding this comment.
looks good. one minor issue
Collaborator
There was a problem hiding this comment.
how about having meaningful names:
s/aIsNull/isNullExpression/g
s/args/arguments/g
s/xx/duplicateIsNullExpression/g
7d13b8e to
dfeed97
Compare
Contributor
Author
|
@zhenxiao I think the checks are passing, mind taking another look? Thanks! |
zhenxiao
approved these changes
Jul 2, 2021
Contributor
|
Hi @zhenxiao / @chliang71 |
Collaborator
|
|
Contributor
Author
|
Thanks @zhenxiao. Seems @ajaygeorge already edited (thanks!) |
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.
Part of simplifyRowExpressionOptimizer execution is eliminates duplicates. Part of execution is the the code below
One scenario is that there can be OR(IS_NULL(a), IS_NULL(a)), i.e. two duplicate IS_NULL on same variable. In this case, the two convertTo*NormalForm call will both simplify it to just one IS_NULL(a) instance, and with form set to IS_NULL (replacing original form = OR). However, this causes trouble for the numOfClauses call later, because current code assumes specialFormExpression must have 2 arguments, while here it is just IS_NULL(a) with only one argument.
It is quite tricky to get to this corner case scenario though, just having a = null or a = null is not enough. I only got one query hitting this, and have been trying to hand craft a query that can cause this. Still have little clue so far, but the query that hit this issue has the core part below hitting the issue:
Interestingly, even slightly tweaking the conditions (e.g. change to col = 'AAA' instead) this issue would not happen.
Test plan - (Please fill in how you tested your changes)
Added unit test.