Github user concretevitamin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1190#discussion_r14114058
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
 ---
    @@ -160,6 +160,43 @@ object HashFilteredJoin extends Logging with 
PredicateHelper {
     }
     
     /**
    + * A pattern that finds joins with equality conditions that can be 
evaluated using equi-join.
    + */
    +object ExtractEquiJoinKeys extends Logging with PredicateHelper {
    +  /** (joinType, rightKeys, leftKeys, condition, leftChild, rightChild) */
    +  type ReturnType =
    +    (JoinType, Seq[Expression], Seq[Expression], Option[Expression], 
LogicalPlan, LogicalPlan)
    +
    +  def unapply(plan: LogicalPlan): Option[ReturnType] = plan match {
    +    case join @ Join(left, right, joinType, condition) =>
    +      logger.debug(s"Considering join on: $condition")
    +      // Find equi-join predicates that can be evaluated before the join, 
and thus can be used
    +      // as join keys.
    +      val (joinPredicates, otherPredicates) = 
condition.map(splitConjunctivePredicates).
    +        getOrElse(Nil).partition {
    +          case EqualTo(l, r) if (canEvaluate(l, left) && canEvaluate(r, 
right)) ||
    +            (canEvaluate(l, right) && canEvaluate(r, left)) => true
    +          case _ => false
    +        }
    +
    +      val joinKeys = joinPredicates.map {
    +        case EqualTo(l, r) if canEvaluate(l, left) && canEvaluate(r, 
right) => (l, r)
    +        case EqualTo(l, r) if canEvaluate(l, right) && canEvaluate(r, 
left) => (r, l)
    +      }
    +      val leftKeys = joinKeys.map(_._1)
    +      val rightKeys = joinKeys.map(_._2)
    +
    +      if(leftKeys.length > 0) {
    --- End diff --
    
    nit: space after if


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to