liupc commented on a change in pull request #23799: [SPARK-26892][CORE] Fix
saveAsTextFile throws NullPointerException when null row present
URL: https://github.com/apache/spark/pull/23799#discussion_r257848300
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1507,24 +1514,7 @@ abstract class RDD[T: ClassTag](
val r = this.mapPartitions { iter =>
val text = new Text()
iter.map { x =>
- text.set(x.toString)
- (NullWritable.get(), text)
- }
- }
- RDD.rddToPairRDDFunctions(r)(nullWritableClassTag, textClassTag, null)
- .saveAsHadoopFile[TextOutputFormat[NullWritable, Text]](path)
- }
-
- /**
- * Save this RDD as a compressed text file, using string representations of
elements.
- */
- def saveAsTextFile(path: String, codec: Class[_ <: CompressionCodec]): Unit
= withScope {
- // https://issues.apache.org/jira/browse/SPARK-2075
- val nullWritableClassTag = implicitly[ClassTag[NullWritable]]
- val textClassTag = implicitly[ClassTag[Text]]
- val r = this.mapPartitions { iter =>
- val text = new Text()
- iter.map { x =>
+ require(x != null, "should not contain null rows")
Review comment:
yea, we can do this nit to make it more clear for users, thank you! I will
update.
----------------------------------------------------------------
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]