Skip to content

Commit decba82

Browse files
committed
Allow repartitioning empty RDDs to zero partitions.
1 parent 97de852 commit decba82

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/src/main/scala/org/apache/spark/rdd/CoalescedRDD.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ private[spark] class CoalescedRDD[T: ClassTag](
7878
balanceSlack: Double = 0.10)
7979
extends RDD[T](prev.context, Nil) { // Nil since we implement getDependencies
8080

81-
require(maxPartitions > 0, s"Number of partitions ($maxPartitions) must be positive.")
81+
require(maxPartitions > 0 || maxPartitions == prev.partitions.length,
82+
s"Number of partitions ($maxPartitions) must be positive.")
8283

8384
override def getPartitions: Array[Partition] = {
8485
val pc = new PartitionCoalescer(maxPartitions, prev, balanceSlack)

0 commit comments

Comments
 (0)