Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11756#discussion_r56325150
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
 ---
    @@ -963,6 +963,28 @@ class JsonSuite extends QueryTest with 
SharedSQLContext with TestJsonData {
         )
       }
     
    +  test("SPARK-13764 Parse modes in JSON data source") {
    +    // `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("a", StringType, true) ::
    +        StructField("b", StringType, true) ::
    +        StructField("c", StringType, true) :: Nil)
    +    assert(schema === jsonDF.schema)
    +
    +    checkAnswer(
    +      jsonDF,
    +      Row("str_a_4", "str_b_4", "str_c_4") :: Nil
    +    )
    +  }
    --- End diff --
    
    Can we add more test cases with user specified schema?


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