-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Fix correctness bug in EffectivePredicateExtractor #23674
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1668,6 +1668,17 @@ public void testInUncorrelatedSubquery() | |
"SELECT TRUE, 2"); | ||
} | ||
|
||
@Test | ||
public void testUncorrelatedSubqueryWithEmptyResult() | ||
{ | ||
assertQuery( | ||
"SELECT regionkey, (select name from nation where false) from region", | ||
"SELECT regionkey, NULL from region"); | ||
assertQuery( | ||
"SELECT regionkey, (select name from nation where nationkey = 5 and mod(nationkey,5) = 1) from region", | ||
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. @jaystarshot The query used here is logically identical to one from the #23660 issue 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. But this current only tests execution and not result expectations? 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. It asserts that results are identical to those from |
||
"SELECT regionkey, NULL from region"); | ||
} | ||
|
||
@Test | ||
public void testChecksum() | ||
{ | ||
|
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.
Bit confused here, as to why do we have the condition to skip if rewritten has variable references? What if the variable reference is pointing to a constant in some project below?
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 guess if it is below, then correctness should already be correct.
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.
If
rewritten
has variable references that arein(variables)
we do not skip them and pull them up (by adding them toeffectiveConjuncts
. The problem here is thatEqaulityInference
is designed to rewrite expressions to just constants (see test), even though, technically this expression does not refer to anyvariables
However, if the
rewritten
expression has no variable references, le.gmod(10,5)=1
- this predicate should not be pulled up, to say, a Join node, because it has no references in the outputs of the Join and cannot impact any predicate inferencing there