Github user davies commented on a diff in the pull request: https://github.com/apache/spark/pull/11327#discussion_r61801165 --- Diff: core/src/main/scala/org/apache/spark/rdd/CoalescedRDD.scala --- @@ -334,8 +332,41 @@ private class DefaultPartitionCoalescer(val balanceSlack: Double = 0.10) } } } else { + // It is possible to have unionRDD where one rdd has preferred locations and another rdd + // that doesn't. To make sure we end up with the requested number of partitions, + // make sure to put a partition in every group. + + if (groupArr.size > initialHash.size) { + // we don't have a partition assigned to every group yet so first try to fill them + // with the partitions with preferred locations + val partIter = partitionLocs.partsWithLocs.iterator + while (partIter.hasNext && initialHash.size < groupArr.size) { + var (nxt_replica, nxt_part) = partIter.next() + if (!initialHash.contains(nxt_part)) { + groupArr.find(pg => pg.numPartitions == 0).map(firstEmpty => { --- End diff -- same here
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org