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

    https://github.com/apache/spark/pull/9940#discussion_r50167918
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFilterSuite.scala
 ---
    @@ -330,9 +331,56 @@ class ParquetFilterSuite extends QueryTest with 
ParquetTest with SharedSQLContex
     
             // If the "c = 1" filter gets pushed down, this query will throw 
an exception which
             // Parquet emits. This is a Parquet issue (PARQUET-389).
    +        val df = sqlContext.read.parquet(pathOne, pathTwo).filter("c = 
1").selectExpr("c", "b", "a")
             checkAnswer(
    -          sqlContext.read.parquet(pathOne, pathTwo).filter("c = 
1").selectExpr("c", "b", "a"),
    +          df,
               (1 to 1).map(i => Row(i, i.toString, null)))
    +
    +        // The fields "a" and "c" only exist in one Parquet file.
    +        df.schema.fields.foreach { f =>
    +          if (f.name == "a" || f.name == "c") {
    +            assert(f.metadata.contains("optional"))
    +          }
    +        }
    +
    +        val pathThree = s"${dir.getCanonicalPath}/table3"
    +        df.write.parquet(pathThree)
    +
    +        // We will remove the temporary metadata when writing Parquet file.
    +        sqlContext.read.parquet(pathThree).schema.fields.foreach { f =>
    +          assert(!f.metadata.contains("optional"))
    +        }
    +
    +        val pathFour = s"${dir.getCanonicalPath}/table4"
    +        val dfStruct = sparkContext.parallelize(Seq((1, 1))).toDF("a", "b")
    +        dfStruct.select(struct("a").as("s")).write.parquet(pathFour)
    +
    +        val pathFive = s"${dir.getCanonicalPath}/table5"
    +        val dfStruct2 = sparkContext.parallelize(Seq((1, 1))).toDF("c", 
"b")
    +        dfStruct2.select(struct("c").as("s")).write.parquet(pathFive)
    +
    +        // If the "s.c = 1" filter gets pushed down, this query will throw 
an exception which
    +        // Parquet emits.
    +        val dfStruct3 = sqlContext.read.parquet(pathFour, 
pathFive).filter("s.c = 1")
    +          .selectExpr("s.c", "s.a")
    +        checkAnswer(
    +          dfStruct3,
    +          (1 to 1).map(i => Row(i, null)))
    +
    +        // The fields "s.a" and "s.c" only exist in one Parquet file.
    +        dfStruct3.schema.fields.foreach { f =>
    +          if (f.name == "s.a" || f.name == "s.c") {
    +            assert(f.metadata.contains("optional"))
    +          }
    +        }
    +
    +        val pathSix = s"${dir.getCanonicalPath}/table6"
    +        dfStruct3.write.parquet(pathSix)
    +
    +        // We will remove the temporary metadata when writing Parquet file.
    +        sqlContext.read.parquet(pathSix).schema.fields.foreach { f =>
    +          assert(!f.metadata.contains("optional"))
    +        }
    --- End diff --
    
    Similar as the other one mentioned above.


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