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

    https://github.com/apache/spark/pull/11756#discussion_r56300778
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
 ---
    @@ -963,6 +963,31 @@ class JsonSuite extends QueryTest with 
SharedSQLContext with TestJsonData {
         )
       }
     
    +  test("SPARK-13764 Parse modes in JSON data source") {
    +    withSQLConf(SQLConf.COLUMN_NAME_OF_CORRUPT_RECORD.key -> "_unparsed") {
    +      // `FAILFAST` mode should throw an exception for corrupt records.
    +      val exception = intercept[SparkException] {
    +        sqlContext.read.option("mode", 
"FAILFAST").json(corruptRecords).collect()
    +      }
    +      assert(exception.getMessage.contains("Malformed line in FAILFAST 
mode: {"))
    +
    +      // `DROPMALFORMED` mode should skip corrupt records
    +      // For `PERMISSIVE` mode, it is tested in "Corrupt records" test.
    +      val jsonDF = sqlContext.read.option("mode", 
"DROPMALFORMED").json(corruptRecords)
    +      val schema = StructType(
    +        StructField("_unparsed", StringType, true) ::
    +          StructField("a", StringType, true) ::
    +          StructField("b", StringType, true) ::
    +          StructField("c", StringType, true) :: Nil)
    +      assert(schema === jsonDF.schema)
    +
    +      checkAnswer(
    +        jsonDF,
    +        Row(null, "str_a_4", "str_b_4", "str_c_4") :: Nil
    --- End diff --
    
    I see. This adds `_corrupt_record` in schema inference. 


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

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

Reply via email to