GitHub user maropu opened a pull request:
https://github.com/apache/spark/pull/16928
[SPARK-18699][SQL] Fill NULL in a field when detecting a malformed token
## What changes were proposed in this pull request?
This pr added a logic to fill NULL when detecting malformed tokens in case
of permissive modes.
In the current master, if the CSV parser hits these malformed tokens, it
throws an exception below (and then a job fails);
```
Caused by: java.lang.IllegalArgumentException
at java.sql.Date.valueOf(Date.java:143)
at
org.apache.spark.sql.catalyst.util.DateTimeUtils$.stringToTime(DateTimeUtils.scala:137)
at
org.apache.spark.sql.execution.datasources.csv.CSVTypeCast$$anonfun$castTo$6.apply$mcJ$sp(CSVInferSchema.scala:272)
at
org.apache.spark.sql.execution.datasources.csv.CSVTypeCast$$anonfun$castTo$6.apply(CSVInferSchema.scala:272)
at
org.apache.spark.sql.execution.datasources.csv.CSVTypeCast$$anonfun$castTo$6.apply(CSVInferSchema.scala:272)
at scala.util.Try.getOrElse(Try.scala:79)
at
org.apache.spark.sql.execution.datasources.csv.CSVTypeCast$.castTo(CSVInferSchema.scala:269)
at
```
In case that users load large CSV-formatted data, the job failure caused by
a few malformed tokens makes users get some confused. So, this fix puts NULL
for the tokens.
## How was this patch tested?
Added tests in `CSVSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/maropu/spark SPARK-18699-2
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/16928.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #16928
----
commit 266819a8e597d74be5ff2001afb638ee72bcdac6
Author: Takeshi Yamamuro <[email protected]>
Date: 2017-02-14T13:26:05Z
Fill NULL in a field when detecting a malformed token
----
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]