Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/16928
  
    @maropu, I just ran some similar tests with JSON datasource. What do you 
think about matching it to JSON's behaviour by introducing 
`columnNameOfCorruptRecord`?
    
    I ran with the data and schema as below:
    
    ```scala
    Seq("""{"a": "a", "b" : 1}""").toDF().write.text("/tmp/path")
    val schema = StructType(StructField("a", IntegerType, true) :: 
StructField("b", StringType, true) :: StructField("_corrupt_record", 
StringType, true) :: Nil)
    ```
    
    **`FAILFAST`**
    
    ```scala
    scala> spark.read.schema(schema).option("mode", 
"FAILFAST").json("/tmp/path").show()
    org.apache.spark.sql.catalyst.json.SparkSQLJsonProcessingException: 
Malformed line in FAILFAST mode: {"a": "a", "b" : 1}
    ```
    
    **`DROPMALFORMED`**
    
    ```scala
    scala> spark.read.schema(schema).option("mode", 
"DROPMALFORMED").json("/tmp/path").show()
    +---+---+---------------+
    |  a|  b|_corrupt_record|
    +---+---+---------------+
    +---+---+---------------+
    ```
    
    **`PERMISSIVE`**
    
    ```scala
    scala> spark.read.schema(schema).option("mode", 
"PERMISSIVE").json("/tmp/path").show()
    +----+----+-------------------+
    |   a|   b|    _corrupt_record|
    +----+----+-------------------+
    |null|null|{"a": "a", "b" : 1}|
    +----+----+-------------------+
    ```
    



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