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

    https://github.com/apache/spark/pull/11809#discussion_r57005499
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala 
---
    @@ -46,22 +46,17 @@ abstract class QueryPlan[PlanType <: 
QueryPlan[PlanType]] extends TreeNode[PlanT
       private def constructIsNotNullConstraints(constraints: Set[Expression]): 
Set[Expression] = {
         // Currently we only propagate constraints if the condition consists 
of equality
         // and ranges. For all other cases, we return an empty set of 
constraints
    -    constraints.map {
    -      case EqualTo(l, r) =>
    -        Set(IsNotNull(l), IsNotNull(r))
    -      case GreaterThan(l, r) =>
    -        Set(IsNotNull(l), IsNotNull(r))
    -      case GreaterThanOrEqual(l, r) =>
    -        Set(IsNotNull(l), IsNotNull(r))
    -      case LessThan(l, r) =>
    -        Set(IsNotNull(l), IsNotNull(r))
    -      case LessThanOrEqual(l, r) =>
    -        Set(IsNotNull(l), IsNotNull(r))
    -      case Not(EqualTo(l, r)) =>
    -        Set(IsNotNull(l), IsNotNull(r))
    -      case _ =>
    -        Set.empty[Expression]
    -    }.foldLeft(Set.empty[Expression])(_ union _.toSet)
    +    constraints.map(scanNullIntolerantExpr)
    +      .foldLeft(Set.empty[Expression])(_ union _.toSet)
    +  }
    +
    +  private def scanNullIntolerantExpr(expr: Expression): Set[Expression] = 
expr match {
    +    case a: Attribute => Set(IsNotNull(a))
    +    case IsNotNull(e) =>
    +      // IsNotNull is null tolerant, but we need to explore for the 
attributes not null.
    +      scanNullIntolerantExpr(e)
    +    case e: Expression if e.nullIntolerant => 
e.children.flatMap(scanNullIntolerantExpr).toSet
    --- End diff --
    
    We can rewrite it in a tailrec way.


---
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