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

    https://github.com/apache/spark/pull/20345#discussion_r180615479
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
 ---
    @@ -172,17 +174,20 @@ object ExtractFiltersAndInnerJoins extends 
PredicateHelper {
         case Filter(filterCondition, j @ Join(left, right, _: InnerLike, 
joinCondition)) =>
           val (plans, conditions) = flattenJoin(j)
           (plans, conditions ++ splitConjunctivePredicates(filterCondition))
    -
    +    case p @ Project(_, j @ Join(_, _, _: InnerLike, _))
    +        // Keep flattening joins when the project has attributes only
    +        if p.projectList.forall(_.isInstanceOf[Attribute]) =>
    +      flattenJoin(j)
         case _ => (Seq((plan, parentJoinType)), Seq.empty)
       }
     
    -  def unapply(plan: LogicalPlan): Option[(Seq[(LogicalPlan, InnerLike)], 
Seq[Expression])]
    -      = plan match {
    -    case f @ Filter(filterCondition, j @ Join(_, _, joinType: InnerLike, 
_)) =>
    -      Some(flattenJoin(f))
    -    case j @ Join(_, _, joinType, _) =>
    -      Some(flattenJoin(j))
    -    case _ => None
    +  def unapply(plan: LogicalPlan): Option[(Seq[(LogicalPlan, InnerLike)], 
Seq[Expression])] = {
    +    val (plans, conditions) = flattenJoin(plan)
    +    if (plans.size > 1) {
    --- End diff --
    
    aha, sounds good to me. Thanks!


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to