wecharyu commented on code in PR #49027:
URL: https://github.com/apache/spark/pull/49027#discussion_r1871688257


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/V1Writes.scala:
##########
@@ -107,7 +107,11 @@ object V1Writes extends Rule[LogicalPlan] with 
SQLConfHelper {
     if (orderingMatched) {
       empty2NullPlan
     } else {
-      Sort(requiredOrdering, global = false, empty2NullPlan)
+      // Preserve the requiredOrdering and append any missing elements from 
outputOrdering.
+      val newOrder = requiredOrdering ++ outputOrdering.filterNot { 
outputOrder =>
+        requiredOrdering.exists(_.child.semanticEquals(outputOrder.child))

Review Comment:
   It should be fine since we are writing data belonging to the same partition 
or bucket into the same files. In your example, the data within each file of a 
partition is sorted by `col1`, as expected.



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