liupc commented on a change in pull request #23799: [SPARK-26892]Fix
saveAsTextFile throws NullPointerException when null row present
URL: https://github.com/apache/spark/pull/23799#discussion_r257485714
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1525,7 +1526,8 @@ abstract class RDD[T: ClassTag](
val r = this.mapPartitions { iter =>
val text = new Text()
iter.map { x =>
- text.set(x.toString)
+ val value = if (x != null) x.toString else "Null"
Review comment:
@attilapiros I think it's good to extract the common parts of these two
call, and also maybe we can just add an require as @HyukjinKwon suggested, it
should be uncommon for users to map null to `Null` string, `saveAsTextFile` can
treat null as an exceptional case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]