Skip to content

Commit 1ab943f

Browse files
committed
IsNull and IsNotNull Parquet filter test case for boolean type
1 parent bcd616b commit 1ab943f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

sql/core/src/test/scala/org/apache/spark/sql/parquet/ParquetFilterSuite.scala

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ import org.apache.spark.sql.{QueryTest, SQLConf, SchemaRDD}
2828
/**
2929
* A test suite that tests Parquet filter2 API based filter pushdown optimization.
3030
*
31-
* Notice that `!(a cmp b)` are always transformed to its negated form `a cmp' b` by the
32-
* `BooleanSimplification` optimization rule whenever possible. As a result, predicate `!(a < 1)`
33-
* results a `GtEq` filter predicate rather than a `Not`.
31+
* NOTE:
3432
*
35-
* @todo Add test cases for `IsNull` and `IsNotNull` after merging PR #3367
33+
* 1. `!(a cmp b)` is always transformed to its negated form `a cmp' b` by the
34+
* `BooleanSimplification` optimization rule whenever possible. As a result, predicate `!(a < 1)`
35+
* results in a `GtEq` filter predicate rather than a `Not`.
36+
*
37+
* 2. `Tuple1(Option(x))` is used together with `AnyVal` types like `Int` to ensure the inferred
38+
* data type is nullable.
3639
*/
3740
class ParquetFilterSuite extends QueryTest with ParquetTest {
3841
val sqlContext = TestSQLContext
@@ -85,7 +88,12 @@ class ParquetFilterSuite extends QueryTest with ParquetTest {
8588
}
8689

8790
test("filter pushdown - boolean") {
88-
withParquetRDD((true :: false :: Nil).map(Tuple1.apply)) { rdd =>
91+
withParquetRDD((true :: false :: Nil).map(b => Tuple1.apply(Option(b)))) { rdd =>
92+
checkFilterPushdown(rdd, '_1)('_1.isNull, classOf[Eq[java.lang.Boolean]])(Seq.empty[Row])
93+
checkFilterPushdown(rdd, '_1)('_1.isNotNull, classOf[NotEq[java.lang.Boolean]]) {
94+
Seq(Row(true), Row(false))
95+
}
96+
8997
checkFilterPushdown(rdd, '_1)('_1 === true, classOf[Eq[java.lang.Boolean]])(true)
9098
checkFilterPushdown(rdd, '_1)('_1 !== true, classOf[Operators.NotEq[java.lang.Boolean]]) {
9199
false

0 commit comments

Comments
 (0)