Skip to content

Commit d271392

Browse files
committed
This rule should be executed after ReplaceNullWithFalseInPredicate
1 parent 425705e commit d271392

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ abstract class Optimizer(catalogManager: CatalogManager)
146146
operatorOptimizationRuleSet: _*) ::
147147
Batch("Push extra predicate through join", fixedPoint,
148148
PushExtraPredicateThroughJoin,
149-
PushDownPredicates) :: Nil
149+
PushDownPredicates) ::
150+
Batch("Pull out complex join condition", Once,
151+
PullOutComplexJoinCondition) :: Nil
150152
}
151153

152154
val batches = (
@@ -289,7 +291,6 @@ abstract class Optimizer(catalogManager: CatalogManager)
289291
ReplaceExpressions,
290292
RewriteNonCorrelatedExists,
291293
PullOutGroupingExpressions,
292-
PullOutComplexJoinCondition,
293294
ComputeCurrentTime,
294295
ReplaceCurrentLike(catalogManager),
295296
SpecialDatetimeValues,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ import org.apache.spark.sql.catalyst.trees.TreePattern.JOIN
3939
* +- Filter isnotnull(x#2)
4040
* +- Relation default.t2[x#2,y#3] parquet
4141
* }}}
42+
*
43+
* This rule should be executed after ReplaceNullWithFalseInPredicate.
4244
*/
4345
object PullOutComplexJoinCondition extends Rule[LogicalPlan] with PredicateHelper {
4446
def apply(plan: LogicalPlan): LogicalPlan = plan.transformUpWithPruning(_.containsPattern(JOIN)) {
45-
case j @ Join(left, right, _, Some(condition), _) if j.resolved =>
47+
case j @ Join(left, right, _, Some(condition), _) if !j.isStreaming =>
4648
val complexExps = splitConjunctivePredicates(condition).flatMap {
4749
case p: Expression => p.children.filter(e => !e.foldable && e.children.nonEmpty)
4850
case _ => Nil

0 commit comments

Comments
 (0)