Skip to content
Snippets Groups Projects
Commit 175c4786 authored by Herman van Hovell's avatar Herman van Hovell Committed by Shixiong Zhu
Browse files

[SPARK-18300][SQL] Fix scala 2.10 build for FoldablePropagation

## What changes were proposed in this pull request?
Commit https://github.com/apache/spark/commit/f14ae4900ad0ed66ba36108b7792d56cd6767a69

 broke the scala 2.10 build. This PR fixes this by simplifying the used pattern match.

## How was this patch tested?
Tested building manually. Ran `build/sbt -Dscala-2.10 -Pscala-2.10 package`.

Author: Herman van Hovell <hvanhovell@databricks.com>

Closes #15891 from hvanhovell/SPARK-18300-scala-2.10.

(cherry picked from commit 4b35d13b)
Signed-off-by: default avatarShixiong Zhu <shixiong@databricks.com>
parent 1126c319
No related branches found
No related tags found
No related merge requests found
......@@ -442,12 +442,9 @@ object FoldablePropagation extends Rule[LogicalPlan] {
case l: LeafNode =>
l
// Whitelist of all nodes we are allowed to apply this rule to.
case p @ (_: Project | _: Filter | _: SubqueryAlias | _: Aggregate | _: Window |
_: Sample | _: GlobalLimit | _: LocalLimit | _: Generate | _: Distinct |
_: AppendColumns | _: AppendColumnsWithObject | _: BroadcastHint |
_: RedistributeData | _: Repartition | _: Sort | _: TypedFilter) if !stop =>
p.transformExpressions(replaceFoldable)
// We can only propagate foldables for a subset of unary nodes.
case u: UnaryNode if !stop && canPropagateFoldables(u) =>
u.transformExpressions(replaceFoldable)
// Allow inner joins. We do not allow outer join, although its output attributes are
// derived from its children, they are actually different attributes: the output of outer
......@@ -474,6 +471,30 @@ object FoldablePropagation extends Rule[LogicalPlan] {
})
}
}
/**
* Whitelist of all [[UnaryNode]]s for which allow foldable propagation.
*/
private def canPropagateFoldables(u: UnaryNode): Boolean = u match {
case _: Project => true
case _: Filter => true
case _: SubqueryAlias => true
case _: Aggregate => true
case _: Window => true
case _: Sample => true
case _: GlobalLimit => true
case _: LocalLimit => true
case _: Generate => true
case _: Distinct => true
case _: AppendColumns => true
case _: AppendColumnsWithObject => true
case _: BroadcastHint => true
case _: RedistributeData => true
case _: Repartition => true
case _: Sort => true
case _: TypedFilter => true
case _ => false
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment