hotienvu commented on a change in pull request #29661:
URL: https://github.com/apache/spark/pull/29661#discussion_r487359185



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/OptimizeInSuite.scala
##########
@@ -238,4 +238,34 @@ class OptimizeInSuite extends PlanTest {
 
     comparePlans(optimized, correctAnswer)
   }
+
+  test("OptimizedIn test: optimize range compare") {
+    val originalQuery = testRelation
+      .select('a)
+      .where('a in(4, 1, 2, 3, 3, 5))
+
+    val optimized = Optimize.execute(originalQuery.analyze)
+
+    val expected = testRelation
+      .select('a)
+      .where('a >= 1 && 'a <= 5)
+      .analyze
+
+    comparePlans(optimized, expected)
+  }
+
+  test("OptimizedIn test: do not optimize range compare if non-continuous") {
+    val originalQuery = testRelation
+      .select('a)
+      .where('a in(1, 2, 3, 3, 5))
+
+    val optimized = Optimize.execute(originalQuery.analyze)
+
+    val expected = testRelation
+      .select('a)
+      .where('a in(1, 2, 3, 5))

Review comment:
       agreed. though I think something like a >=1 && a <= 3 and a == 5 would 
be more simple to implement. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to