Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/16067#discussion_r90176972
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala
---
@@ -58,13 +57,28 @@ abstract class QueryPlan[PlanType <:
QueryPlan[PlanType]] extends TreeNode[PlanT
}
/**
+ * Infer the Attribute-specific IsNotNull constraints from the null
intolerant child expressions
+ * of constraints.
+ */
+ private def inferIsNotNullConstraints(constraint: Expression):
Seq[Expression] =
+ constraint match {
+ case IsNotNull(_: Attribute) => constraint :: Nil
+ // When the root is IsNotNull, we can push IsNotNull through the
child null intolerant
+ // expressions
+ case IsNotNull(expr) =>
scanNullIntolerantExpr(expr).map(IsNotNull(_))
+ // Constraints always return true for all the inputs. That means,
null will never be returned.
+ // Thus, we can infer `IsNotNull(constraint)`, and also push
IsNotNull through the child
+ // null intolerant expressions.
+ case _ => scanNullIntolerantExpr(constraint).map(IsNotNull(_))
+ }
+
+ /**
* Recursively explores the expressions which are null intolerant and
returns all attributes
* in these expressions.
*/
private def scanNullIntolerantExpr(expr: Expression): Seq[Attribute] =
expr match {
--- End diff --
shall we rename it to `scanNullIntolerantAttribute`?
---
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]