Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/10844#discussion_r51330946
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala
---
@@ -180,6 +229,55 @@ case class Join(
}
}
+ override protected def validConstraints: 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
+ def constructIsNotNullConstraints(condition: Expression):
Set[Expression] = {
+ splitConjunctivePredicates(condition).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 _ =>
+ Set.empty[Expression]
+ }.foldLeft(Set.empty[Expression])(_ union _.toSet)
+ }
+
+ def constructIsNullConstraints(plan: LogicalPlan): Set[Expression] = {
+ plan.output.map(IsNull).toSet
+ }
+
+ (joinType match {
+ case Inner if condition.isDefined =>
+ getRelevantConstraints(left)
+ .union(getRelevantConstraints(right))
+ .union(constructIsNotNullConstraints(condition.get))
+ case LeftSemi if condition.isDefined =>
+ getRelevantConstraints(left)
+ .union(getRelevantConstraints(right))
+ .union(constructIsNotNullConstraints(condition.get))
+ case LeftOuter =>
+ getRelevantConstraints(left)
+ .union(constructIsNullConstraints(right))
+ case RightOuter =>
+ getRelevantConstraints(right)
+ .union(constructIsNullConstraints(left))
+ case FullOuter =>
+ constructIsNullConstraints(left)
+ .union(constructIsNullConstraints(right))
+ case _ =>
--- End diff --
What types of joins are we not handling? It might be better to get an
exception if we add a new type and its not handled, but I'm not sure.
---
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]