Skip to content

Commit 6337c77

Browse files
committed
Improve EliminateOuterJoin performance
1 parent 091cbc3 commit 6337c77

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ abstract class UnaryNode extends LogicalPlan {
170170
* original constraint expressions with the corresponding alias
171171
*/
172172
protected def getAllValidConstraints(projectList: Seq[NamedExpression]): Set[Expression] = {
173-
var allConstraints = child.constraints.asInstanceOf[Set[Expression]]
173+
val childConstraints = child.constraints
174+
var allConstraints = childConstraints.asInstanceOf[Set[Expression]]
174175
projectList.foreach {
175176
case a @ Alias(l: Literal, _) =>
176177
allConstraints += EqualNullSafe(a.toAttribute, l)
177178
case a @ Alias(e, _) =>
178179
// For every alias in `projectList`, replace the reference in constraints by its attribute.
179-
allConstraints ++= allConstraints.map(_ transform {
180+
allConstraints ++= childConstraints.map(_ transform {
180181
case expr: Expression if expr.semanticEquals(e) =>
181182
a.toAttribute
182183
})

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,13 @@ class ConstraintPropagationSuite extends SparkFunSuite with PlanTest {
135135
ExpressionSet(Seq(resolveColumn(aliasedRelation.analyze, "x") > 10,
136136
IsNotNull(resolveColumn(aliasedRelation.analyze, "x")),
137137
resolveColumn(aliasedRelation.analyze, "b") <=> resolveColumn(aliasedRelation.analyze, "y"),
138-
resolveColumn(aliasedRelation.analyze, "z") <=> resolveColumn(aliasedRelation.analyze, "x"),
139138
resolveColumn(aliasedRelation.analyze, "z") > 10,
140139
IsNotNull(resolveColumn(aliasedRelation.analyze, "z")))))
141140

142141
val multiAlias = tr.where('a === 'c + 10).select('a.as('x), 'c.as('y))
143142
verifyConstraints(multiAlias.analyze.constraints,
144143
ExpressionSet(Seq(IsNotNull(resolveColumn(multiAlias.analyze, "x")),
145-
IsNotNull(resolveColumn(multiAlias.analyze, "y")),
146-
resolveColumn(multiAlias.analyze, "x") === resolveColumn(multiAlias.analyze, "y") + 10))
144+
IsNotNull(resolveColumn(multiAlias.analyze, "y"))))
147145
)
148146
}
149147

0 commit comments

Comments
 (0)