cloud-fan commented on a change in pull request #32872:
URL: https://github.com/apache/spark/pull/32872#discussion_r649658095



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/CustomShuffleReaderExec.scala
##########
@@ -87,8 +87,22 @@ case class CustomShuffleReaderExec private(
     Iterator(desc)
   }
 
-  def hasCoalescedPartition: Boolean =
-    partitionSpecs.exists(_.isInstanceOf[CoalescedPartitionSpec])
+  private def isCoalesced(spec: ShufflePartitionSpec) = coalesceRange(spec) > 1
+
+  /**
+   * How many partitions were coalesced; 0 if not [[CoalescedPartitionSpec]]
+   */
+  private def coalesceRange(spec: ShufflePartitionSpec) = spec match {
+    case s: CoalescedPartitionSpec => s.endReducerIndex - s.startReducerIndex
+    case _ => 0
+  }
+
+  /**
+   * Returns true iff some non-empty partitions were combined
+   */
+  def hasCoalescedPartition: Boolean = {
+    partitionSpecs.exists(isCoalesced)

Review comment:
       nit:
   ```
   partitionSpecs.exists {
     case s: CoalescedPartitionSpec => s.endReducerIndex - s.startReducerIndex
     case _ => false
   }
   ```

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala
##########
@@ -1567,7 +1567,7 @@ class AdaptiveQueryExecSuite
         assert(!smj.head.isSkewJoin)
         // Both sides are coalesced.
         val customReaders = collect(smj.head) {
-          case c: CustomShuffleReaderExec if c.hasCoalescedPartition => c
+          case c: CustomShuffleReaderExec => c

Review comment:
       so this test actually do not coalesce the partitions?




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to