You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/01/18 23:48:33 UTC
[GitHub] [spark] sunchao commented on a change in pull request #35225: [SPARK-35703][SQL][FOLLOWUP] ValidateRequirements should check the co-partitioning requirement
sunchao commented on a change in pull request #35225:
URL: https://github.com/apache/spark/pull/35225#discussion_r787237910
##########
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:
nit: maybe we can add a `logDebug` here too
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org