wangyum commented on code in PR #42488:
URL: https://github.com/apache/spark/pull/42488#discussion_r1301748287
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala:
##########
@@ -673,6 +673,21 @@ class PlannerSuite extends SharedSparkSession with
AdaptiveSparkPlanHelper {
shouldHaveSort = true)
}
+ test("SPARK-44804: SortMergeJoin should respect the streamed side ordering")
{
+ val plan1 = DummySparkPlan(outputOrdering = Seq(orderingA, orderingB),
+ outputPartitioning = HashPartitioning(exprA :: Nil, 5))
+ val plan2 = DummySparkPlan(outputOrdering = Seq(orderingB, orderingC,
orderingA),
+ outputPartitioning = HashPartitioning(exprB :: Nil, 5))
+
+ Seq(Inner -> 2,
+ LeftOuter -> 2,
+ RightOuter -> 3,
+ FullOuter -> 0).foreach { case (joinType, orderNum) =>
+ val smj = SortMergeJoinExec(exprA :: Nil, exprB :: Nil, joinType, None,
plan1, plan2)
+ assert(smj.outputOrdering.length == orderNum)
+ }
Review Comment:
```scala
def assertOrdering(plan: SparkPlan, expectedOrdering: Seq[String]): Unit
= {
assert(plan.outputOrdering.map(_.sql) === expectedOrdering)
}
assertOrdering(
SortMergeJoinExec(Seq(exprA), Seq(exprB), Inner, None, plan1, plan2),
Seq("1 ASC NULLS FIRST", "2 ASC NULLS FIRST"))
assertOrdering(
SortMergeJoinExec(Seq(exprB), Seq(exprA), Inner, None, plan2, plan1),
Seq("2 ASC NULLS FIRST", "3 ASC NULLS FIRST", "1 ASC NULLS 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]