You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/15 16:31:56 UTC

[GitHub] attilapiros commented on a change in pull request #23799: [SPARK-26892]Fix saveAsTextFile throws NullPointerException when null row present

attilapiros 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_r257304118
 
 

 ##########
 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:
   This two methods are very much the same. 
   
   I have quickly checked what is at the end of the call chain:
   org.apache.spark.rdd.PairRDDFunctions#saveAsHadoopFile
   
   There the default value of the codec is None (as there it is wrapped within an Option). 
   Would not it make sense to extract these common parts? 
   
   If that is too much still up to the calling of `.saveAsHadoopFile[TextOutputFormat[NullWritable, Text]](path)` they are common. What is your opinion?
    
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org