Github user junegunn commented on the issue:
https://github.com/apache/spark/pull/16347
@cloud-fan Unfortunately, yes.
```scala
sc.parallelize(1 to 10000000).toDS.withColumn("part", 'value.mod(2))
.repartition(1, 'part).sortWithinPartitions("value")
.write.mode("overwrite").format("orc").partitionBy("part")
.saveAsTable("test_sort_within")
```
For the above case, `requiredOrdering` is `part` and `actualOrdering` is
`value`, so SortExec runs anyway and the ordering within the partition is not
respected if spill occurs.
However, we now have a workaround; prepend partition columns to
`sortWithinPartitions` call or `SORT BY` clause, i.e.
`.sortWithinPartitions("part", "value")`, to bypass SortExec.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]