You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/09/10 17:09:21 UTC

[GitHub] [spark] Tagar commented on a change in pull request #29661: [SPARK-32811][SQL] optimize IN predicate against continuous range

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



##########
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:
       might be optimized into 
   > 'a >= 1 && 'a <= 5 && 'a != 4 
   ? 
   May not make a lot of sense for this simple use case, but for a longer IN list this would be nice to be covered as well. 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org