Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16156#discussion_r90972713
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFilterSuite.scala
 ---
    @@ -578,4 +578,66 @@ class ParquetFilterSuite extends QueryTest with 
ParquetTest with SharedSQLContex
           // scalastyle:on nonascii
         }
       }
    +
    +  test("SPARK-18539 - filtered by non-existing parquet column") {
    +    Seq("parquet").foreach { format =>
    +      withSQLConf(SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED.key -> "true") {
    +        withTempPath { path =>
    +          import testImplicits._
    +          Seq((1, "abc"), (2, "hello")).toDF("a", 
"b").write.format(format).save(path.toString)
    +
    +          // user-specified schema contains nonexistent columns
    +          val schema = StructType(
    +            Seq(StructField("a", IntegerType),
    +              StructField("b", StringType),
    +              StructField("c", IntegerType)))
    +          val readDf1 = 
spark.read.schema(schema).format(format).load(path.toString)
    +
    +          // Read the table without any filter
    +          checkAnswer(readDf1, Row(1, "abc", null) :: Row(2, "hello", 
null) :: Nil)
    +          // Read the table with a filter on existing columns
    +          checkAnswer(readDf1.filter("a < 2"), Row(1, "abc", null) :: Nil)
    +
    +          // Read the table with a filter on nonexistent columns
    +          checkAnswer(readDf1.filter("c < 2"), Nil)
    +          checkAnswer(readDf1.filter("c is not null"), Nil)
    +
    +          checkAnswer(readDf1.filter("c is null"),
    +            Row(1, "abc", null) :: Row(2, "hello", null) :: Nil)
    +
    +          checkAnswer(readDf1.filter("c is null and a < 2"),
    +            Row(1, "abc", null) :: Nil)
    +
    +          // With another parquet file that contains the column "c"
    +          Seq((2, "abc", 3), (3, "hello", 4)).toDF("a", "b", "c")
    +            .write.format(format).mode(SaveMode.Append).save(path.toString)
    +
    +          // Right now, there are 2 parquet files. one with the column "c",
    +          // the other does not have it.
    +          val readDf2 = 
spark.read.schema(schema).format(format).load(path.toString)
    --- End diff --
    
    Yea, what I concern is that we are using the vectorized Parquet reader by 
default now and may not have enough test coverage of the normal Parquet reader. 
Would be good to have test cases to prevent regression for the normal Parquet 
reader code path.


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

Reply via email to