Skip to content

Commit f4dbf50

Browse files
committed
Update ConstantFoldingSuite.scala
1 parent 35ceb7a commit f4dbf50

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ConstantFoldingSuite.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ConstantFoldingSuite extends PlanTest {
3535
Batch("AnalysisNodes", Once,
3636
EliminateSubQueries) ::
3737
Batch("ConstantFolding", Once,
38+
OptimizeIn,
3839
ConstantFolding,
3940
BooleanSimplification) :: Nil
4041
}
@@ -247,4 +248,36 @@ class ConstantFoldingSuite extends PlanTest {
247248

248249
comparePlans(optimized, correctAnswer)
249250
}
251+
252+
test("Constant folding test: Fold In(v, list) into true or false") {
253+
var originalQuery =
254+
testRelation
255+
.select('a)
256+
.where(In(Literal(1), Seq(Literal(1), Literal(2))))
257+
258+
var optimized = Optimize(originalQuery.analyze)
259+
260+
var correctAnswer =
261+
testRelation
262+
.select('a)
263+
.where(Literal(true))
264+
.analyze
265+
266+
comparePlans(optimized, correctAnswer)
267+
268+
originalQuery =
269+
testRelation
270+
.select('a)
271+
.where(In(Literal(1), Seq(Literal(1), 'a.attr)))
272+
273+
optimized = Optimize(originalQuery.analyze)
274+
275+
correctAnswer =
276+
testRelation
277+
.select('a)
278+
.where(Literal(true))
279+
.analyze
280+
281+
comparePlans(optimized, correctAnswer)
282+
}
250283
}

0 commit comments

Comments
 (0)