GitHub user dima-asana opened a pull request:

    https://github.com/apache/spark/pull/22759

    [MINOR][SQL][DOC] Correct parquet nullability documentation

    ## What changes were proposed in this pull request?
    
    Parquet files appear to have nullability info when being written, not being 
read.
    
    ## How was this patch tested?
    
    Some test code: (running spark 2.3, but the relevant code in DataSource 
looks identical on master)
    
    case class NullTest(bo: Boolean, opbol: Option[Boolean])
    val testDf = spark.createDataFrame(Seq(NullTest(true, Some(false))))
    
    defined class NullTest
    testDf: org.apache.spark.sql.DataFrame = [bo: boolean, opbol: boolean]
    
    testDf.write.parquet("s3://asana-stats/tmp_dima/parquet_check_schema")
    
    
spark.read.parquet("s3://asana-stats/tmp_dima/parquet_check_schema/part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet4").printSchema()
    root
     |-- bo: boolean (nullable = true)
     |-- opbol: boolean (nullable = true)
    
    
    Meanwhile, the parquet file formed does have nullable info:
    
    []batch@prod-report000:/tmp/dimakamalov-batch$ aws s3 ls 
s3://asana-stats/tmp_dima/parquet_check_schema/
    2018-10-17 21:03:52          0 _SUCCESS
    2018-10-17 21:03:50        504 
part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
    []batch@prod-report000:/tmp/dimakamalov-batch$ aws s3 cp 
s3://asana-stats/tmp_dima/parquet_check_schema/part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
 .
    download: 
s3://asana-stats/tmp_dima/parquet_check_schema/part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
 to ./part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
    []batch@prod-report000:/tmp/dimakamalov-batch$ java -jar 
parquet-tools-1.8.2.jar schema 
part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet 
    message spark_schema {
      required boolean bo;
      optional boolean opbol;
    }


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dima-asana/spark 
dima-asana-nullable-parquet-doc

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/22759.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22759
    
----
commit 0c6ae5621e0fee76f836bdc6ec504685b7983a75
Author: dima-asana <42555784+dima-asana@...>
Date:   2018-10-17T21:08:50Z

    Correct parquet nullability documentation
    
    Parquet files appear to have nullability info when being written, not being 
read.  Some test code:
    
    case class NullTest(bo: Boolean, opbol: Option[Boolean])
    val testDf = spark.createDataFrame(Seq(NullTest(true, Some(false))))
    
    defined class NullTest
    testDf: org.apache.spark.sql.DataFrame = [bo: boolean, opbol: boolean]
    
    testDf.write.parquet("s3://asana-stats/tmp_dima/parquet_check_schema")
    
    
spark.read.parquet("s3://asana-stats/tmp_dima/parquet_check_schema/part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet4").printSchema()
    root
     |-- bo: boolean (nullable = true)
     |-- opbol: boolean (nullable = true)
    
    
    Meanwhile, the parquet file formed does have nullable info:
    
    []batch@prod-report000:/tmp/dimakamalov-batch$ aws s3 ls 
s3://asana-stats/tmp_dima/parquet_check_schema/
    2018-10-17 21:03:52          0 _SUCCESS
    2018-10-17 21:03:50        504 
part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
    []batch@prod-report000:/tmp/dimakamalov-batch$ aws s3 cp 
s3://asana-stats/tmp_dima/parquet_check_schema/part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
 .
    download: 
s3://asana-stats/tmp_dima/parquet_check_schema/part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
 to ./part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet
    []batch@prod-report000:/tmp/dimakamalov-batch$ java -jar 
parquet-tools-1.8.2.jar schema 
part-00000-b1bf4a19-d9fe-4ece-a2b4-9bbceb490857-c000.snappy.parquet 
    message spark_schema {
      required boolean bo;
      optional boolean opbol;
    }

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to