cloud-fan commented on code in PR #44429:
URL: https://github.com/apache/spark/pull/44429#discussion_r1432902953
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/V1WriteCommandSuite.scala:
##########
@@ -270,15 +270,24 @@ class V1WriteCommandSuite extends QueryTest with
SharedSparkSession with V1Write
}
// assert the outer most sort in the executed plan
- assert(plan.collectFirst {
- case s: SortExec => s
- }.exists {
- case SortExec(Seq(
- SortOrder(AttributeReference("value", StringType, _, _),
Ascending, NullsFirst, _),
- SortOrder(AttributeReference("key", IntegerType, _, _), Ascending,
NullsFirst, _)
- ), false, _, _) => true
- case _ => false
- }, plan)
+ val sort = plan.collectFirst { case s: SortExec => s }
+ if (enabled) {
+ // With planned write, optimizer is more efficient and can eliminate
`SORT BY value, key`.
Review Comment:
This is a good side effect of this change. Before this PR, there is a
conflict in `EliminateSorts`: ideally we remove the bottom Sort and keep the
top Sort, but if the child sort ordering satisfies the top Sort, we remove top
Sort. This is inconsistent and also suboptimal as we sort by more keys.
Now we have fixed the conflict. We always remove bottom Sort first.
--
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]