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



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
##########
@@ -137,8 +138,16 @@ case class EnsureRequirements(
         Some(finalCandidateSpecs.values.maxBy(_.numPartitions))
       }
 
+      // Check if 1) all children are of `KeyGroupedPartitioning` and 2) they 
are all compatible
+      // with each other. If both are true, skip shuffle.
+      val allCompatible = childrenIndexes.sliding(2).map {
+            case Seq(a, b) =>
+              checkKeyGroupedSpec(specs(a)) && checkKeyGroupedSpec(specs(b)) &&

Review comment:
       Do we need `checkKeyGroupedSpec`? It looks like we can always eliminate 
shuffles if all the children are compatible. We can update 
`KeyGroupedShuffleSpec.isCompatible` to always return false if the feature flag 
is off.

##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
##########
@@ -137,8 +138,16 @@ case class EnsureRequirements(
         Some(finalCandidateSpecs.values.maxBy(_.numPartitions))
       }
 
+      // Check if 1) all children are of `DataSourcePartitioning` and 2) they 
are all compatible
+      // with each other. If both are true, skip shuffle.
+      val allCompatible = childrenIndexes.sliding(2).map {
+            case Seq(a, b) =>
+              checkDataSourceSpec(specs(a)) && checkDataSourceSpec(specs(b)) &&
+                  specs(a).isCompatibleWith(specs(b))
+          }.forall(_ == true)
+
       children = children.zip(requiredChildDistributions).zipWithIndex.map {
-        case ((child, _), idx) if !childrenIndexes.contains(idx) =>
+        case ((child, _), idx) if allCompatible || 
!childrenIndexes.contains(idx) =>

Review comment:
       you are right




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