Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/18200
  
    @maropu, I think it is fine. It only happens when the malformed column is 
selected. For example,
    
    The case below is fine
    
    ```scala
    scala> import org.apache.spark.sql.types._
    import org.apache.spark.sql.types._
    
    scala> spark.read.schema(new StructType().add("a", IntegerType).add("b", 
IntegerType)).csv("test.csv").show
    +---+----+
    |  a|   b|
    +---+----+
    |  1|   3|
    |  1|null|
    +---+----+
    ```
    
    but it only happens when malformed column is selected:
    
    ```scala
    scala> import org.apache.spark.sql.types._
    import org.apache.spark.sql.types._
    
    scala> spark.read.schema(new StructType().add("a", IntegerType).add("b", 
IntegerType).add("_corrupt_record", StringType)).csv("test.csv").show
    17/06/07 05:54:55 ERROR Executor: Exception in task 0.0 in stage 1.0 (TID 1)
    java.lang.NullPointerException
        at 
scala.collection.immutable.StringLike$class.stripLineEnd(StringLike.scala:89)
        at scala.collection.immutable.StringOps.stripLineEnd(StringOps.scala:29)
        at 
org.apache.spark.sql.execution.datasources.csv.UnivocityParser.org$apache$spark$sql$execution$datasources$csv$UnivocityParser$$getCurrentInput(UnivocityParser.scala:56)
        at 
org.apache.spark.sql.execution.datasources.csv.UnivocityParser$$anonfun$org$apache$spark$sql$execution$datasources$csv$UnivocityParser$$convert$1.apply(UnivocityParser.scala:211)
        at 
org.apache.spark.sql.execution.datasources.csv.UnivocityParser$$anonfun$org$apache$spark$sql$execution$datasources$csv$UnivocityParser$$convert$1.apply(UnivocityParser.scala:211)
        at 
org.apache.spark.sql.execution.datasources.FailureSafeParser$$anonfun$2.apply(FailureSafeParser.scala:50)
        at 
org.apache.spark.sql.execution.datasources.FailureSafeParser$$anonfun$2.apply(FailureSafeParser.scala:43)
        at 
org.apache.spark.sql.execution.datasources.FailureSafeParser.parse(FailureSafeParser.scala:64)
    ```
    
    I think we introduced `columnNameOfCorruptRecord` option in CSV in 2.2.0 - 
https://issues.apache.org/jira/browse/SPARK-18699. So, I guess this is not a 
regression (but a bug we should definitely fix).


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