peter-toth commented on code in PR #58273:
URL: https://github.com/apache/spark/pull/58273#discussion_r3863088585


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/physical/partitioning.scala:
##########
@@ -613,9 +613,12 @@ case class KeyedPartitioning(
       val joinKeyPositions = 
result.keyPositions.map(_.nonEmpty).zipWithIndex.filter(_._1).map(_._2)
       val projectedExpressions = joinKeyPositions.map(expressions)
       val projectedKeys = projectKeys(joinKeyPositions)._2
-      val distinctProjectedKeys = projectedKeys.distinct
+      // Sort the distinct projected keys the same way `GroupPartitionsExec` 
does. Otherwise, when
+      // only the keyed side is grouped and the other side is re-shuffled 
using this spec, the two
+      // `KeyedPartitioning`s carry the same keys in a different order and
+      // `PartitioningCollection.fromPartitionings` rejects them.
       val projectedPartitioning =
-        KeyedPartitioning(projectedExpressions, distinctProjectedKeys, 
isGrouped = true)
+        new KeyedPartitioning(projectedExpressions, projectedKeys, isGrouped = 
false).toGrouped

Review Comment:
   Here is the follow-up: https://github.com/apache/spark/pull/58311



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