@@ -28,11 +28,14 @@ import org.apache.spark.sql.{QueryTest, SQLConf, SchemaRDD}
28
28
/**
29
29
* A test suite that tests Parquet filter2 API based filter pushdown optimization.
30
30
*
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:
34
32
*
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.
36
39
*/
37
40
class ParquetFilterSuite extends QueryTest with ParquetTest {
38
41
val sqlContext = TestSQLContext
@@ -85,7 +88,12 @@ class ParquetFilterSuite extends QueryTest with ParquetTest {
85
88
}
86
89
87
90
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
+
89
97
checkFilterPushdown(rdd, ' _1 )(' _1 === true , classOf [Eq [java.lang.Boolean ]])(true )
90
98
checkFilterPushdown(rdd, ' _1 )(' _1 !== true , classOf [Operators .NotEq [java.lang.Boolean ]]) {
91
99
false
0 commit comments