Skip to content
Prev Previous commit
Next Next commit
add null test
  • Loading branch information
ulysses-you committed Feb 26, 2021
commit 0dc1c4a7829ea7261688cebeabc1638245fd4ede
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,27 @@ class FiltersSuite extends SparkFunSuite with Logging with PlanTest {
"datecol != 2019-01-01")

filterTest("not-in int filter",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a test case for NULL as while, e.g. NOT IN (1, 2, ..., NULL)? Given we have bug before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should be, add the null value for test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems exists some issue about null value. Created #31659.

(Not(In(a("intcol", IntegerType), Seq(Literal(1), Literal(2))))) :: Nil,
(Not(In(a("intcol", IntegerType), Seq(Literal(1), Literal(2), Literal(null))))) :: Nil,
"(intcol != 1 and intcol != 2)")

filterTest("not-in string filter",
(Not(In(a("strcol", StringType), Seq(Literal("a"), Literal("b"))))) :: Nil,
(Not(In(a("strcol", StringType), Seq(Literal("a"), Literal("b"), Literal(null))))) :: Nil,
"""(strcol != "a" and strcol != "b")""")

filterTest("not-inset, int filter",
(Not(InSet(a("intcol", IntegerType), Set(1, 2)))) :: Nil,
(Not(InSet(a("intcol", IntegerType), Set(1, 2, null)))) :: Nil,
"(intcol != 1 and intcol != 2)")

filterTest("not-inset, string filter",
(Not(InSet(a("strcol", StringType), Set(Literal("a").eval(), Literal("b").eval())))) :: Nil,
(Not(InSet(a("strcol", StringType),
Set(Literal("a").eval(), Literal("b").eval(), Literal(null).eval())))) :: Nil,
"""(strcol != "a" and strcol != "b")""")

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,
Literal(Date.valueOf("2020-01-02")).eval(),
Literal(null).eval())))) :: Nil,
"""(datecol != 2020-01-01 and datecol != 2020-01-02)""")

// Applying the predicate `x IN (NULL)` should return an empty set, but since this optimization
Expand Down