Skip to content

Commit

Permalink
Update ConstantFoldingSuite.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
pzzs committed May 7, 2015
1 parent 35ceb7a commit f4dbf50
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ConstantFoldingSuite extends PlanTest {
Batch("AnalysisNodes", Once,
EliminateSubQueries) ::
Batch("ConstantFolding", Once,
OptimizeIn,
ConstantFolding,
BooleanSimplification) :: Nil
}
Expand Down Expand Up @@ -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(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(originalQuery.analyze)

correctAnswer =
testRelation
.select('a)
.where(Literal(true))
.analyze

comparePlans(optimized, correctAnswer)
}
}

0 comments on commit f4dbf50

Please sign in to comment.