File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments