EnricoMi commented on code in PR #38356:
URL: https://github.com/apache/spark/pull/38356#discussion_r1021131560
##########
sql/core/src/test/scala/org/apache/spark/sql/sources/PartitionedWriteSuite.scala:
##########
@@ -220,6 +220,23 @@ class PartitionedWriteSuite extends QueryTest with
SharedSparkSession {
}
}
}
+
+ test("SPARK-40885: V1 write uses the sort with partitionBy operator") {
+ withTempPath { f =>
+ Seq((20, 30, "partition"), (15, 20, "partition"),
+ (30, 70, "partition"), (18, 40, "partition"))
+ .toDF("id", "sort_col", "p")
+ .repartition(1)
+ .sortWithinPartitions("p", "sort_col")
+ .write
+ .partitionBy("p")
Review Comment:
> I'm not very sure what the problem is.
See https://github.com/apache/spark/pull/38356#issuecomment-1302534716:
The `V1Writes` rule introduced in Spark 3.4 adds the `empty2null` to all
nullable string partition columns. The modified `V1WriteCommand` then has a
modified `write.requiredOrdering` but the old `write.query.outputOrdering`,
which then do not match any more. In `FileFormatWriter`, the outer sort will be
added because of that mismatch.
--
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]