mgaido91 commented on a change in pull request #23267: [SPARK-25401] [SQL]
Reorder join predicates to match child outputOrdering
URL: https://github.com/apache/spark/pull/23267#discussion_r251786866
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
##########
@@ -243,24 +250,38 @@ case class EnsureRequirements(conf: SQLConf) extends
Rule[SparkPlan] {
(leftKeysBuffer, rightKeysBuffer)
}
- private def reorderJoinKeys(
+ private def reorderJoinKeys[A](
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
- leftPartitioning: Partitioning,
- rightPartitioning: Partitioning): (Seq[Expression], Seq[Expression]) = {
+ leftChildDist: A,
+ rightChildDist: A): (Seq[Expression], Seq[Expression]) = {
if (leftKeys.forall(_.deterministic) && rightKeys.forall(_.deterministic))
{
- leftPartitioning match {
+ leftChildDist match {
case HashPartitioning(leftExpressions, _)
if leftExpressions.length == leftKeys.length &&
leftKeys.forall(x => leftExpressions.exists(_.semanticEquals(x)))
=>
reorder(leftKeys, rightKeys, leftExpressions, leftKeys)
- case _ => rightPartitioning match {
+ case leftOrders: Seq[_]
+ if leftOrders.forall(_.isInstanceOf[Expression]) &&
+ leftOrders.length == leftKeys.length &&
+ leftKeys.forall { x =>
+
(leftOrders.map(_.asInstanceOf[Expression])).exists(_.semanticEquals(x))} =>
+ reorder(leftKeys, rightKeys,
leftOrders.map(_.asInstanceOf[Expression]), leftKeys)
+
+ case _ => rightChildDist match {
case HashPartitioning(rightExpressions, _)
if rightExpressions.length == rightKeys.length &&
rightKeys.forall(x =>
rightExpressions.exists(_.semanticEquals(x))) =>
reorder(leftKeys, rightKeys, rightExpressions, rightKeys)
+ case rightOrders: Seq[_]
+ if rightOrders.forall(_.isInstanceOf[Expression]) &&
+ rightOrders.length == leftKeys.length &&
+ leftKeys.forall { x =>
+
(rightOrders.map(_.asInstanceOf[Expression])).exists(_.semanticEquals(x))} =>
+ reorder(leftKeys, rightKeys,
rightOrders.map(_.asInstanceOf[Expression]), leftKeys)
Review comment:
```
reorder(leftKeys, rightKeys, rightOrders.map(_.asInstanceOf[Expression]),
rigthKeys)
```
and please add a UT which fails before correcting this and passes after.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]