Skip to content

Commit cc0262c

Browse files
committed
address comments.
1 parent 6977fdf commit cc0262c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ object OuterJoinElimination extends Rule[LogicalPlan] with PredicateHelper {
950950
* Returns whether the expression returns null or false when all inputs are nulls.
951951
*/
952952
private def canFilterOutNull(e: Expression): Boolean = {
953+
if (!e.deterministic) return false
953954
val attributes = e.references.toSeq
954955
val emptyRow = new GenericInternalRow(attributes.length)
955956
val v = BindReferences.bindReference(e, attributes).eval(emptyRow)
@@ -988,7 +989,8 @@ object OuterJoinElimination extends Rule[LogicalPlan] with PredicateHelper {
988989

989990
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
990991
case f @ Filter(condition, j @ Join(_, _, RightOuter | LeftOuter | FullOuter, _)) =>
991-
Filter(condition, buildNewJoin(f, j))
992+
val newJoin = buildNewJoin(f, j)
993+
if (j.joinType == newJoin.joinType) f else Filter(condition, newJoin)
992994
}
993995
}
994996

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ abstract class QueryPlan[PlanType <: TreeNode[PlanType]] extends TreeNode[PlanTy
5656
Set(IsNotNull(l), IsNotNull(r))
5757
case LessThanOrEqual(l, r) =>
5858
Set(IsNotNull(l), IsNotNull(r))
59-
case EqualNullSafe(l, r) if !r.nullable || !l.nullable =>
60-
Set(IsNotNull(l), IsNotNull(r))
6159
case _ =>
6260
Set.empty[Expression]
6361
}.foldLeft(Set.empty[Expression])(_ union _.toSet)

sql/core/src/test/scala/org/apache/spark/sql/JoinSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class JoinSuite extends QueryTest with SharedSQLContext {
8181
("SELECT * FROM testData JOIN testData2 ON key = a where key = 2", classOf[SortMergeJoin]),
8282
("SELECT * FROM testData LEFT JOIN testData2 ON key = a", classOf[SortMergeOuterJoin]),
8383
("SELECT * FROM testData RIGHT JOIN testData2 ON key = a where key = 2",
84-
classOf[SortMergeJoin]), // conversion from Right Outer to Inner
84+
classOf[SortMergeJoin]), // converted from Right Outer to Inner
8585
("SELECT * FROM testData right join testData2 ON key = a and key = 2",
8686
classOf[SortMergeOuterJoin]),
8787
("SELECT * FROM testData full outer join testData2 ON key = a",

0 commit comments

Comments
 (0)