Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9348#discussion_r43478044
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/OptimizeInSuite.scala
---
@@ -82,4 +83,35 @@ class OptimizeInSuite extends PlanTest {
comparePlans(optimized, correctAnswer)
}
+
+ test("OptimizedIn test: NULL IN (expr1, ..., exprN) gets transformed to
Filter(null)") {
+ val originalQuery =
+ testRelation
+ .where(In(Literal.create(null, NullType), Seq(Literal(1),
Literal(2))))
+ .analyze
+
+ val optimized = Optimize.execute(originalQuery.analyze)
+ val correctAnswer =
+ testRelation
+ .where(Literal.create(null, BooleanType))
+ .analyze
+
+ comparePlans(optimized, correctAnswer)
+ }
+
+ test("OptimizedIn test: Inset optimization disabled as " +
+ "list expression contains attribute)") {
+ val originalQuery =
+ testRelation
+ .where(In(Literal.create(null, StringType), Seq(Literal(1),
UnresolvedAttribute("b"))))
+ .analyze
+
+ val optimized = Optimize.execute(originalQuery.analyze)
+ val correctAnswer =
+ testRelation
+ .where(Literal.create(null, BooleanType))
+ .analyze
+
+ comparePlans(optimized, correctAnswer)
+ }
--- End diff --
Can you add a test that has `In(Literal.create(null, StringType),
Seq(Literal(1), UnresolvedAttribute("b")))` in the select clause? I think we
need to make sure it returns `null`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]