dongjoon-hyun commented on code in PR #58345:
URL: https://github.com/apache/spark/pull/58345#discussion_r3874276710


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/ShuffleExchangeExec.scala:
##########
@@ -463,8 +465,22 @@ object ShuffleExchangeExec {
         val projection = 
UnsafeProjection.create(sortingExpressions.map(_.child), outputAttributes)
         row => projection(row)
       case SinglePartition => identity
-      case KeyedPartitioning(expressions, _, _, _) =>
-        row => bindReferences(expressions, outputAttributes).map(_.eval(row))
+      case k: KeyedPartitioning =>
+        val expressions = bindReferences(k.expressions, 
outputAttributes).toArray
+        // Wrap the evaluated partition key so it compares equal to the 
KeyGroupedPartitioner's
+        // map keys (the partitioning's own wrappers) under `RowOrdering` 
semantics. The wrapped
+        // row is reused across records; KeyGroupedPartitioner does not retain 
lookup keys.
+        val wrapperFactory = InternalRowComparableWrapper
+          .getInternalRowComparableWrapperFactory(k.expressionDataTypes)

Review Comment:
   Thank you always, @sunchao !



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