c21 commented on a change in pull request #35225:
URL: https://github.com/apache/spark/pull/35225#discussion_r787250534



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/ValidateRequirements.scala
##########
@@ -45,23 +45,24 @@ object ValidateRequirements extends Logging {
     assert(requiredChildDistributions.length == children.length)
     assert(requiredChildOrderings.length == children.length)
 
-    // Verify partition number. For (hash) clustered distribution, the 
corresponding children must
-    // have the same number of partitions.
-    val numPartitions = requiredChildDistributions.zipWithIndex.collect {
-      case (_: ClusteredDistribution, i) => i
-    }.map(i => children(i).outputPartitioning.numPartitions)
-    if (numPartitions.length > 1 && !numPartitions.tail.forall(_ == 
numPartitions.head)) {
-      logDebug(s"ValidateRequirements failed: different partition num 
in\n$plan")
-      return false
-    }
-
-    
children.zip(requiredChildDistributions.zip(requiredChildOrderings)).forall {
+    val satisfied = 
children.zip(requiredChildDistributions.zip(requiredChildOrderings)).forall {
       case (child, (distribution, ordering))
           if !child.outputPartitioning.satisfies(distribution)
             || !SortOrder.orderingSatisfies(child.outputOrdering, ordering) =>
         logDebug(s"ValidateRequirements failed: $distribution, 
$ordering\n$plan")
         false
       case _ => true
     }
+
+    if (satisfied && children.length > 1 &&
+      
requiredChildDistributions.forall(_.isInstanceOf[ClusteredDistribution])) {
+      // Check the co-partitioning requirement.
+      val specs = 
children.map(_.outputPartitioning).zip(requiredChildDistributions).map {
+        case (p, d) => 
p.createShuffleSpec(d.asInstanceOf[ClusteredDistribution])
+      }
+      specs.tail.forall(_.isCompatibleWith(specs.head))

Review comment:
       +1 for maintaining existing behavior.




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

Reply via email to