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

    https://github.com/apache/spark/pull/20816#discussion_r175550955
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -669,11 +672,42 @@ object InferFiltersFromConstraints extends 
Rule[LogicalPlan] with PredicateHelpe
           val newConditionOpt = conditionOpt match {
             case Some(condition) =>
               val newFilters = additionalConstraints -- 
splitConjunctivePredicates(condition)
    -          if (newFilters.nonEmpty) Option(And(newFilters.reduce(And), 
condition)) else None
    +          if (newFilters.nonEmpty) Option(And(newFilters.reduce(And), 
condition)) else conditionOpt
             case None =>
               additionalConstraints.reduceOption(And)
           }
    -      if (newConditionOpt.isDefined) Join(left, right, joinType, 
newConditionOpt) else join
    +      // Infer filter for left/right outer joins
    +      val newLeftOpt = joinType match {
    +        case RightOuter if newConditionOpt.isDefined =>
    +          val rightConstraints = right.constraints.union(
    +            splitConjunctivePredicates(newConditionOpt.get).toSet)
    +          val inferredConstraints = ExpressionSet(
    +            
QueryPlanConstraints.inferAdditionalConstraints(rightConstraints))
    +          val leftConditions = inferredConstraints
    --- End diff --
    
    I had the same inclination of wrapping the evaluation of `allConstraints` 
in a helper function too, till I realized that `constructIsNotNullConstraints` 
would depend on the LogicalPlan node in addition to the input constraints. 
`constructIsNotNullConstraints` has two parts, one being to deduce is-not-null 
from null-intolerant expressions, the other to deduce is-null-not from 
attribute nullability. We could reorganize these pieces into new methods, but I 
feel like we should wait till we find an actual usage so to figure out what 
needs to be included in the helper function.


---

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

Reply via email to