-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-7437][SQL] Fold "literal in (item1, item2, ..., literal, ...)" into true or false directly #5972
[SPARK-7437][SQL] Fold "literal in (item1, item2, ..., literal, ...)" into true or false directly #5972
Changes from all commits
c3f046f
cb1852d
c87e8b6
161cae3
98b134f
d00303b
802261c
34b1a9a
f61210c
f12fa50
f03fe7f
14952e2
2e8f6ca
36c194e
35ceb7a
f4dbf50
24739bd
e34c28a
fa461a5
abe2bbb
4c722a2
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ class ConstantFoldingSuite extends PlanTest { | |
Batch("AnalysisNodes", Once, | ||
EliminateSubQueries) :: | ||
Batch("ConstantFolding", Once, | ||
OptimizeIn, | ||
ConstantFolding, | ||
BooleanSimplification) :: Nil | ||
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. @marmbrus Seems we need to add all of the rules shown in Analyzer's "ConstantFolding" to here? 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. The initial plan here was to only include the rules we are testing. I'm not sure if its true here, but sometimes including all the rules make it harder to test since then you need something that won't be optimized away by unrelated rules. |
||
} | ||
|
@@ -247,4 +248,36 @@ class ConstantFoldingSuite extends PlanTest { | |
|
||
comparePlans(optimized, correctAnswer) | ||
} | ||
|
||
test("Constant folding test: Fold In(v, list) into true or false") { | ||
var originalQuery = | ||
testRelation | ||
.select('a) | ||
.where(In(Literal(1), Seq(Literal(1), Literal(2)))) | ||
|
||
var optimized = Optimize.execute(originalQuery.analyze) | ||
|
||
var correctAnswer = | ||
testRelation | ||
.select('a) | ||
.where(Literal(true)) | ||
.analyze | ||
|
||
comparePlans(optimized, correctAnswer) | ||
|
||
originalQuery = | ||
testRelation | ||
.select('a) | ||
.where(In(Literal(1), Seq(Literal(1), 'a.attr))) | ||
|
||
optimized = Optimize.execute(originalQuery.analyze) | ||
|
||
correctAnswer = | ||
testRelation | ||
.select('a) | ||
.where(Literal(true)) | ||
.analyze | ||
|
||
comparePlans(optimized, correctAnswer) | ||
} | ||
} |
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.
Why move it?
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.
because it more like a transform, i think it should before ConstantFolding @yhuai
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.
All of them are in the batch of "ConstantFolding". So, we do not really need to move them, right?
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.
Not necessary, but looks ok to me, here first do transform from in -> inset, then in ConstantFolding it will call InSet.eval (not In.eval) which should be more efficient.