Github user sureshthalamati commented on the pull request:
https://github.com/apache/spark/pull/12904#issuecomment-217765505
I am not sure what was the history behind returning empty String for null
value. In my opinion it should be null be default. current behavior is also
inconsistent; for numerics it will return null and for strings it will return
empty string by default.
Example:
See the Year (int), and comment (String in the following data).
year,make,model,comment,price
2017,Tesla,Mode 3,looks nice.,35000.99
,Chevy,Bolt,,29000.00
2015,Porsche,"",,
scala> val df= sqlContext.read.format("csv").option("header",
"true").option("inferSchema", "true").load("/tmp/test1.csv")
df: org.apache.spark.sql.DataFrame = [year: int, make: string ... 3 more
fields]
scala> df.show
+----+-------+------+-----------+--------+
|year| make| model| comment| price|
+----+-------+------+-----------+--------+
|2017| Tesla|Mode 3|looks nice.|35000.99|
|null| Chevy| Bolt| | 29000.0|
|2015|Porsche| null| | null|
+----+-------+------+-----------+--------+
I can update this PR to change the nullValue default if needed,
---
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]