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_r251822818
##########
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:
I meant a test like the one you added. But please, first do prove that the
current solution is fine (since I doubt so, see
https://github.com/apache/spark/pull/23267#issuecomment-458528158). Once we
ensure that the current change is safe, you can go ahead addressing these
comments. Thanks.
----------------------------------------------------------------
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]