@@ -606,11 +606,12 @@ object NullPropagation extends Rule[LogicalPlan] {
606606object NullFiltering extends Rule [LogicalPlan ] with PredicateHelper {
607607 def apply (plan : LogicalPlan ): LogicalPlan = plan transform {
608608 case filter @ Filter (condition, child) =>
609- // We generate a list of additional isNotNull filters from the operator's existing constraints
610- // but remove those that are either already part of the filter condition or are part of the
611- // operator's child constraints.
612- val newIsNotNullConstraints = filter.constraints.filter(_.isInstanceOf [IsNotNull ]) --
613- (child.constraints ++ splitConjunctivePredicates(condition))
609+ // We generate a list of additional isNotNull filters from the operator's existing
610+ // non-compound constraints but remove those that are either already part of the filter
611+ // condition or are part of the operator's child constraints.
612+ val newIsNotNullConstraints =
613+ filter.constraints.filter(isNullFilteringForNonCompoundExpr) --
614+ (child.constraints ++ splitConjunctivePredicates(condition))
614615 if (newIsNotNullConstraints.nonEmpty) {
615616 Filter (And (newIsNotNullConstraints.reduce(And ), condition), child)
616617 } else {
@@ -619,11 +620,11 @@ object NullFiltering extends Rule[LogicalPlan] with PredicateHelper {
619620
620621 case join @ Join (left, right, joinType, condition) =>
621622 val leftIsNotNullConstraints = join.constraints
622- .filter(_. isInstanceOf [ IsNotNull ] )
623+ .filter(isNullFilteringForNonCompoundExpr )
623624 .filter(_.references.subsetOf(left.outputSet)) -- left.constraints
624625 val rightIsNotNullConstraints =
625626 join.constraints
626- .filter(_. isInstanceOf [ IsNotNull ] )
627+ .filter(isNullFilteringForNonCompoundExpr )
627628 .filter(_.references.subsetOf(right.outputSet)) -- right.constraints
628629 val newLeftChild = if (leftIsNotNullConstraints.nonEmpty) {
629630 Filter (leftIsNotNullConstraints.reduce(And ), left)
@@ -641,6 +642,12 @@ object NullFiltering extends Rule[LogicalPlan] with PredicateHelper {
641642 join
642643 }
643644 }
645+ private def isNullFilteringForNonCompoundExpr (exp : Expression ): Boolean = {
646+ exp match {
647+ case c : IsNotNull if c.child.isInstanceOf [AttributeReference ] => true
648+ case _ => false
649+ }
650+ }
644651}
645652
646653/**
0 commit comments