[
https://issues.apache.org/jira/browse/SPARK-17916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15591408#comment-15591408
]
Hyukjin Kwon commented on SPARK-17916:
--------------------------------------
[~falaki] I just have thought about this more but I started to feel we might
not need this.
I tested {{read.csv()}} in R as well after setting the equalvalent default
values in Spark CSV options.
{code}
> d <- "col1,col2
+ 1,\"-\"
+ 2,\"\""
> df <- read.csv(text=d, quote="\"", na.strings=c("-"))
> df
col1 col2
1 1 NA
2 2 NA
{code}
It seems {{read.csv()}} in R seems not having this option[1] and handles
equalvalently with the current behaviour of Spark CSV dataource.
Shouldn't we maybe do this as below?
{code}
> df <- read.csv(text=d, quote="", na.strings=c("\"-\""))
> df
col1 col2
1 1 <NA>
2 2 ""
{code}
I am not saying we should exactly match {{read.csv()}} in R to {{read.csv()}}
in Spark but maybe I guess it'd be nicer if the behaviour is matched up in
general.
I guess we could add this option (as you pointed out) but I am worried if this
brings some confusions between {{nullValue}} and {{emptyValue}} as pointed out
in the PR.
[1]https://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html
> CSV data source treats empty string as null no matter what nullValue option is
> ------------------------------------------------------------------------------
>
> Key: SPARK-17916
> URL: https://issues.apache.org/jira/browse/SPARK-17916
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.0.1
> Reporter: Hossein Falaki
>
> When user configures {{nullValue}} in CSV data source, in addition to those
> values, all empty string values are also converted to null.
> {code}
> data:
> col1,col2
> 1,"-"
> 2,""
> {code}
> {code}
> spark.read.format("csv").option("nullValue", "-")
> {code}
> We will find a null in both rows.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]