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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]