ulysses-you commented on a change in pull request #31646:
URL: https://github.com/apache/spark/pull/31646#discussion_r591043266



##########
File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/client/FiltersSuite.scala
##########
@@ -108,6 +108,52 @@ class FiltersSuite extends SparkFunSuite with Logging with 
PlanTest {
     (a("datecol", DateType) =!= Literal(Date.valueOf("2019-01-01"))) :: Nil,
     "datecol != 2019-01-01")
 
+  filterTest("not-in int filter",
+    (Not(In(a("intcol", IntegerType), Seq(Literal(1), Literal(2))))) :: Nil,
+    "(intcol != 1 and intcol != 2)")
+
+  filterTest("not-in int filter with null",
+    (Not(In(a("intcol", IntegerType), Seq(Literal(1), Literal(2), 
Literal(null))))) :: Nil,
+    "")
+
+  filterTest("not-in string filter",
+    (Not(In(a("strcol", StringType), Seq(Literal("a"), Literal("b"))))) :: Nil,
+    """(strcol != "a" and strcol != "b")""")
+
+  filterTest("not-in string filter with null",
+    (Not(In(a("strcol", StringType), Seq(Literal("a"), Literal("b"), 
Literal(null))))) :: Nil,
+    "")
+
+  filterTest("not-inset, int filter",
+    (Not(InSet(a("intcol", IntegerType), Set(1, 2)))) :: Nil,
+    "(intcol != 1 and intcol != 2)")
+
+  filterTest("not-inset, int filter with null",
+    (Not(InSet(a("intcol", IntegerType), Set(1, 2, null)))) :: Nil,
+    "")
+
+  filterTest("not-inset, string filter",
+    (Not(InSet(a("strcol", StringType), Set(Literal("a").eval(), 
Literal("b").eval())))) :: Nil,
+    """(strcol != "a" and strcol != "b")""")
+
+  filterTest("not-inset, string filter with null",
+    (Not(InSet(a("strcol", StringType),
+      Set(Literal("a").eval(), Literal("b").eval(), Literal(null).eval())))) 
:: Nil,
+    "")
+
+  filterTest("not-inset, date filter",
+    (Not(InSet(a("datecol", DateType),
+      Set(Literal(Date.valueOf("2020-01-01")).eval(),
+        Literal(Date.valueOf("2020-01-02")).eval())))) :: Nil,
+    """(datecol != 2020-01-01 and datecol != 2020-01-02)""")
+
+  filterTest("not-inset, date filter with null",
+    (Not(InSet(a("datecol", DateType),
+      Set(Literal(Date.valueOf("2020-01-01")).eval(),
+        Literal(Date.valueOf("2020-01-02")).eval(),
+        Literal(null).eval())))) :: Nil,
+    "")
+

Review comment:
       The expected result is wrong in null test case before so it passed. Has 
added new test case for both with null or not.  e.g. `not-in string filter with 
null`.




----------------------------------------------------------------
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