maryannxue commented on a change in pull request #27833: [SPARK-31070][SQL]
make skew join split skewed partitions more evenly
URL: https://github.com/apache/spark/pull/27833#discussion_r389462567
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeSkewedJoin.scala
##########
@@ -115,18 +115,32 @@ case class OptimizeSkewedJoin(conf: SQLConf) extends
Rule[SparkPlan] {
partitionStartIndices += 0
var i = 0
var postMapPartitionSize = 0L
+ var lastPackagedPartitionSize = -1L
while (i < mapPartitionSizes.length) {
val nextMapPartitionSize = mapPartitionSizes(i)
if (i > 0 && postMapPartitionSize + nextMapPartitionSize > targetSize) {
partitionStartIndices += i
+ lastPackagedPartitionSize = postMapPartitionSize
postMapPartitionSize = nextMapPartitionSize
} else {
postMapPartitionSize += nextMapPartitionSize
}
i += 1
}
- partitionStartIndices.toArray
+ if (lastPackagedPartitionSize > -1) {
+ val lastPartitionDiff = math.abs(targetSize - postMapPartitionSize)
+ val diffIfMergeLastPartition = math.abs(
+ lastPackagedPartitionSize + postMapPartitionSize - targetSize)
+ // If the last partition is very small, we should merge it to the
previous partition.
+ if (lastPartitionDiff > diffIfMergeLastPartition * 2) {
Review comment:
Shouldn't it always be larger than targetSize?? otherwise the two splits
would have been one in the first place.
----------------------------------------------------------------
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.
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]