rekbun commented on code in PR #60256:
URL: https://github.com/apache/spark/pull/60256#discussion_r4603465086
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/GroupPartitionsExec.scala:
##########
@@ -863,37 +867,73 @@ private[sql] object GroupPartitionsExec {
*
* Unlike Spark's default coalescer which tries to minimize data movement,
this coalescer
* groups partitions based on their partition keys to maintain the grouping
semantics
- * required for storage-partitioned operations.
+ * required for storage-partitioned operations. A group of several partitions
prefers the host that
+ * most of them prefer. A group of one partition, and every group over
persisted data, leaves its
+ * location to the scheduler.
*
* @param groupedPartitions Sequence where each element is a sequence of input
partition
- * indices that should be grouped together
+ * indices that should be grouped together. Only the
driver reads it,
+ * so it is not serialized into tasks.
*/
class GroupedPartitionCoalescer(
- val groupedPartitions: Seq[Seq[Int]]
+ @transient val groupedPartitions: Seq[Seq[Int]]
) extends PartitionCoalescer with Serializable {
override def coalesce(maxPartitions: Int, parent: RDD[_]):
Array[PartitionGroup] = {
+ require(groupedPartitions.size == maxPartitions,
s"GroupedPartitionCoalescer has " +
+ s"${groupedPartitions.size} groups but was asked for $maxPartitions
partitions")
+ // The scheduler looks cached blocks up when it submits each stage, while
the groups get their
+ // locations once, when the partitions are computed. So over persisted
data the groups leave
+ // their locations to the scheduler.
+ val voting = !GroupedPartitionCoalescer.persistedLineage(parent)
Review Comment:
Done in 114d73e0790. The description's zip paragraph now names this cost and
when it applies: only where the join zips the grouped RDDs directly. With a
`ColumnarToRowExec` or `SortExec` in between, the zip has no locations of its
own, and the scheduler walks the zip's first side (the streamed side under
whole-stage codegen), as on master. The zip test now has a cached side against
a side over a map whose group names h3, and it also checks that the scheduler
alone would offer the executor that holds the block.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]