wangyum commented on code in PR #42488:
URL: https://github.com/apache/spark/pull/42488#discussion_r1297263553
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala:
##########
@@ -78,13 +78,21 @@ case class SortMergeJoinExec(
* again, returns the required ordering for this child with extra
"sameOrderExpressions" from
* the child's outputOrdering.
*/
- private def getKeyOrdering(keys: Seq[Expression], childOutputOrdering:
Seq[SortOrder])
- : Seq[SortOrder] = {
+ private def getKeyOrdering(
+ keys: Seq[Expression],
+ childOutputOrdering: Seq[SortOrder],
+ isStreamSide: Boolean = true) : Seq[SortOrder] = {
val requiredOrdering = requiredOrders(keys)
if (SortOrder.orderingSatisfies(childOutputOrdering, requiredOrdering)) {
- keys.zip(childOutputOrdering).map { case (key, childOrder) =>
- val sameOrderExpressionsSet = ExpressionSet(childOrder.children) - key
- SortOrder(key, Ascending, sameOrderExpressionsSet.toSeq)
+ val newRequiredOrdering =
+ keys.zip(childOutputOrdering).map { case (key, childOrder) =>
+ val sameOrderExpressionsSet = ExpressionSet(childOrder.children) -
key
+ SortOrder(key, Ascending, sameOrderExpressionsSet.toSeq)
+ }
+ if (isStreamSide) {
+ newRequiredOrdering ++ childOutputOrdering.drop(requiredOrdering.size)
+ } else {
+ newRequiredOrdering
Review Comment:
```suggestion
keys.zip(childOutputOrdering).map { case (key, childOrder) =>
val sameOrderExpressionsSet = ExpressionSet(childOrder.children) -
key
SortOrder(key, Ascending, sameOrderExpressionsSet.toSeq)
} ++ {
if (isKeepRemainingOrder)
childOutputOrdering.drop(requiredOrdering.size) else Nil
```
?
--
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]