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 {
35
35
Batch (" AnalysisNodes" , Once ,
36
36
EliminateSubQueries ) ::
37
37
Batch (" ConstantFolding" , Once ,
38
+ OptimizeIn ,
38
39
ConstantFolding ,
39
40
BooleanSimplification ) :: Nil
40
41
}
@@ -247,4 +248,36 @@ class ConstantFoldingSuite extends PlanTest {
247
248
248
249
comparePlans(optimized, correctAnswer)
249
250
}
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
+ }
250
283
}
You can’t perform that action at this time.
0 commit comments