spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gatorsmile <...@git.apache.org>
Subject [GitHub] spark pull request #16386: [SPARK-18352][SQL] Support parsing multiline json...
Date Thu, 16 Feb 2017 07:49:37 GMT
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16386#discussion_r101460558
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
---
    @@ -1802,4 +1806,118 @@ class JsonSuite extends QueryTest with SharedSQLContext with TestJsonData
{
         val df2 = spark.read.option("PREfersdecimaL", "true").json(records)
         assert(df2.schema == schema)
       }
    +
    +  test("SPARK-18352: Parse normal multi-line JSON files (compressed)") {
    +    withTempPath { dir =>
    +      val path = dir.getCanonicalPath
    +      primitiveFieldAndType
    +        .toDF("value")
    +        .write
    +        .option("compression", "GzIp")
    +        .text(path)
    +
    +      assert(new File(path).listFiles().exists(_.getName.endsWith(".gz")))
    +
    +      val jsonDF = spark.read.option("wholeFile", true).json(path)
    +      val jsonDir = new File(dir, "json").getCanonicalPath
    +      jsonDF.coalesce(1).write
    +        .format("json")
    +        .option("compression", "gZiP")
    +        .save(jsonDir)
    +
    +      assert(new File(jsonDir).listFiles().exists(_.getName.endsWith(".json.gz")))
    +
    +      val jsonCopy = spark.read
    +        .format("json")
    +        .load(jsonDir)
    +
    +      assert(jsonCopy.count === jsonDF.count)
    +      val jsonCopySome = jsonCopy.selectExpr("string", "long", "boolean")
    +      val jsonDFSome = jsonDF.selectExpr("string", "long", "boolean")
    --- End diff --
    
    Actually, it only covers three columns.
    ```
    root
     |-- bigInteger: decimal(20,0) (nullable = true)
     |-- boolean: boolean (nullable = true)
     |-- double: double (nullable = true)
     |-- integer: long (nullable = true)
     |-- long: long (nullable = true)
     |-- null: string (nullable = true)
     |-- string: string (nullable = true)
    
    root
     |-- bigInteger: decimal(20,0) (nullable = true)
     |-- boolean: boolean (nullable = true)
     |-- double: double (nullable = true)
     |-- integer: long (nullable = true)
     |-- long: long (nullable = true)
     |-- string: string (nullable = true)
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message