Uh oh!
There was an error while loading. Please reload this page.
[SPARK-12594] [SQL] Outer Join Elimination by Filter Conditions - #10567
[SPARK-12594] [SQL] Outer Join Elimination by Filter Conditions#10567gatorsmile wants to merge 35 commits into
Conversation
SparkQA
commented
Jan 4, 2016
Test build #48633 has finished for PR 10567 at commit
|
SparkQA
commented
Jan 4, 2016
Test build #48634 has finished for PR 10567 at commit
|
There was a problem hiding this comment.
Can you document the arguments here?
@sameeragarwal it would be great if we could replace this function with your more general null propagation information
/cc @yhuai
There was a problem hiding this comment.
@gatorsmile now that we propagate IsNotNull constraints in the logical plan, you should be able to eliminate outer joins by simply looking into the constraints of the parent filter operator. I believe something along the lines this should work:
objectOuterJoinEliminationextendsRule[LogicalPlan] withPredicateHelper {
privatedefbuildNewJoin(filter: Filter, join: Join):Join= {
valleftHasNonNullPredicate= filter.constraints.filter(_.isInstanceOf[IsNotNull])
.exists(expr => join.left.outputSet.intersect(expr.references).nonEmpty)
valrightHasNonNullPredicate= filter.constraints.filter(_.isInstanceOf[IsNotNull])
.exists(expr => join.right.outputSet.intersect(expr.references).nonEmpty)
join.joinType match {
caseRightOuterif leftHasNonNullPredicate =>Join(join.left, join.right, Inner, join.condition)
caseLeftOuterif rightHasNonNullPredicate =>Join(join.left, join.right, Inner, join.condition)
caseFullOuterif leftHasNonNullPredicate && rightHasNonNullPredicate =>Join(join.left, join.right, Inner, join.condition)
caseFullOuterif leftHasNonNullPredicate =>Join(join.left, join.right, LeftOuter, join.condition)
caseFullOuterif rightHasNonNullPredicate =>Join(join.left, join.right, RightOuter, join.condition)
case _ =>
join
}
}
defapply(plan: LogicalPlan):LogicalPlan= plan transform {
case f @Filter(condition, j@Join(_, _, RightOuter|LeftOuter|FullOuter, _)) =>Filter(condition, buildNewJoin(f, j))
}
}There was a problem hiding this comment.
Thank you very much! Will do the changes.
SparkQA
commented
Feb 11, 2016
Test build #51088 has finished for PR 10567 at commit
|
SparkQA
commented
Feb 11, 2016
Test build #51098 has started for PR 10567 at commit |
shaneknapp
commented
Feb 11, 2016
jenkins, test this please |
SparkQA
commented
Feb 11, 2016
Test build #51115 has finished for PR 10567 at commit
|
There was a problem hiding this comment.
I think we can support all the expressions that will return null or false, if the inputs are null.
There was a problem hiding this comment.
With your changes, we can support all the expressions whose attributes are all from left or right, no matter how complicated they are!!!
There was a problem hiding this comment.
With @sameeragarwal changes, we can support the expressions containing both left and right attributes but the types are limited to EqualTo, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, and EqualNullSafe.
We need both!
SparkQA
commented
Feb 18, 2016
Test build #51499 has finished for PR 10567 at commit
|
11b3214 to
6977fdfCompareSparkQA
commented
Feb 19, 2016
Test build #51520 has finished for PR 10567 at commit
|
| } | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan transform { | ||
| case f @ Filter(condition, j @ Join(_, _, RightOuter | LeftOuter | FullOuter, _)) => |
There was a problem hiding this comment.
return the original f if it's not changed
SparkQA
commented
Feb 19, 2016
Test build #51570 has finished for PR 10567 at commit
|
| } | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan transform { | ||
| case f @ Filter(condition, j @ Join(_, _, RightOuter | LeftOuter | FullOuter, _)) => |
There was a problem hiding this comment.
It's better to return JoinType from buildNewJoin
davies
commented
Feb 20, 2016
LGTM, pending tests. |
SparkQA
commented
Feb 20, 2016
Test build #51587 has finished for PR 10567 at commit
|
davies
commented
Feb 20, 2016
Merging this into master, thanks! |
Conversion of outer joins, if the predicates in filter conditions can restrict the result sets so that all null-supplying rows are eliminated.
full outer->innerif both sides have such predicatesleft outer->innerif the right side has such predicatesright outer->innerif the left side has such predicatesfull outer->left outerif only the left side has such predicatesfull outer->right outerif only the right side has such predicatesIf applicable, this can greatly improve the performance, since outer join is much slower than inner join, full outer join is much slower than left/right outer join.
The original PR is #10542