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

    https://github.com/apache/spark/pull/11618#discussion_r55636107
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala 
---
    @@ -62,6 +63,25 @@ abstract class QueryPlan[PlanType <: 
QueryPlan[PlanType]] extends TreeNode[PlanT
       }
     
       /**
    +   * Infers an additional set of constraints from a given set of equality 
constraints.
    +   * For e.g., if an operator has constraints of the form (`a = 5`, `a = 
b`), this returns an
    +   * additional constraint of the form `b = 5`
    +   */
    +  private def inferAdditionalConstraints(constraints: Set[Expression]): 
Set[Expression] = {
    +    constraints.map {
    +      case eq @ EqualTo(l: Attribute, r: Attribute) =>
    +        (constraints -- Set(eq)).map(_ transform {
    +          case a: Attribute if a.semanticEquals(l) => r
    +        }).union(
    +          (constraints -- Set(eq)).map(_ transform {
    +            case a: Attribute if a.semanticEquals(r) => l
    +          }))
    +      case _ =>
    +        Set.empty[Expression]
    +    }.foldLeft(Set.empty[Expression])(_ union _) -- constraints
    --- End diff --
    
    maybe not foldLeft -- most of the time fold is used it can be rewritten 
into something imperative that is simpler (and a lot faster)


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to