Skip to content

Conversation

@kubatyszko
Copy link

What changes were proposed in this pull request?

CSV parser changes allowing parsing of numeric fields to fail and return null in such case.
In conjunction with "nullValue" option that may be used elsewhere this allows handling of certain csv sources that may use empty string as indication of null in one column and another specific value indicating null in another.

Currently the option "nullValue" can only be provided once and we can't assume that a data source won't have a single "null" indicator.

This problem is very similar to the one discussed here: https://github.com/databricks/spark-csv/issues/239

Sargis Dudaklayan and Kuba Tyszko - Zest Finance

How was this patch tested?

The patch was tested using freshly compiled spark version 2.0.1 on a sample data source that has "null" values in 2 columns, one specified as "NA" and set using nullValue and another column with "" indicating no integer value.

Please review http://spark.apache.org/contributing.html before opening a pull request.

…fields - Sargis Dudaklayan and Kuba Tyszko - Zest Finance
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@HyukjinKwon
Copy link
Member

HyukjinKwon commented Dec 17, 2016

Can you describe which case this PR fixes (with reproducible codes)? I think you meant https://issues.apache.org/jira/browse/SPARK-18699

case _: LongType => datum.toLong
case _: ShortType => Try(datum.toShort).getOrElse(null)
case _: IntegerType => Try(datum.toInt).getOrElse(null)
case _: LongType => Try(datum.toLong).getOrElse(null)
Copy link
Member

@HyukjinKwon HyukjinKwon Dec 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I guess you meant when the actual data is empty string and nullValue is other values such as NA, they should be translated into null when the mode is PERMISSIVE in this case.

Then, this is a exact duplicate of https://issues.apache.org/jira/browse/SPARK-18699. You could resolve the current JIRA as a duplicate and then fix the title of this PR to [SPARK-18699] ... with some changes suggested there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, fixed the title. Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use Try for each type here? In the JIRA, I proposed another approach (master...maropu:SPARK-18699), and I think the fix is more natural. Anyway, ISTM we do not decide yet it is worth fixing this issue...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My patch was created before I even knew about SPARK-18699 (I did have another ticket open, then learned it was a duplicate).
I do agree that your solution may be more generic and intuitive, if others agree - why wasn't it merged into main tree yet ? (it has been over 10 days since your PR).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavior changes are much arguable, so it basically takes much time to discuss.

@kubatyszko kubatyszko changed the title SPARK-18906 SQL - parsing CSV should return null for certain numeric … [SPARK-18906] SQL - parsing CSV should return null for certain numeric … Dec 17, 2016
@kubatyszko kubatyszko changed the title [SPARK-18906] SQL - parsing CSV should return null for certain numeric … [SPARK-18699] SQL - parsing CSV should return null for certain numeric … Dec 17, 2016
@HyukjinKwon
Copy link
Member

HyukjinKwon commented Dec 17, 2016

Let's put [WIP] in the PR title, for example, ([WIP][SPARK-18699] ... ) to let other reviewers know this is "Work in process" if you are working on this to follow the suggestion in the JIRA. It seems we need to update the PR description (and with a proper PR title without truncated part such as ...) and need a test in CSVSuite.

Let me please cc @maropu and @falaki here who were in the JIRA.

@maropu
Copy link
Member

maropu commented Dec 17, 2016

@HyukjinKwon Thanks for your pinging! I left some comments.

@kubatyszko kubatyszko changed the title [SPARK-18699] SQL - parsing CSV should return null for certain numeric … [WiP][SPARK-18699] SQL - parsing CSV should return null for certain numeric … Dec 17, 2016
@HyukjinKwon
Copy link
Member

Hi @kubatyszko, are you still working on this? If you are currently unable to proceed further, maybe it should be closed for now. It seems inactive for few months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants