Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Disable Project Push Down Through Filter
  • Loading branch information
gatorsmile committed Mar 13, 2016
commit e128a0a3d23b7a6a37cdc77034a651d79e32c451
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ object ColumnPruning extends Rule[LogicalPlan] {
case j @ Join(left, right, LeftSemi, condition) =>
j.copy(right = prunedChild(right, j.references))

// Project should not be pushed below Filter. See PushPredicateThroughProject
case p @ Project(_, _: Filter) => p

// all the columns will be used to compare, so we can't prune them
case p @ Project(_, _: SetOperation) => p
case p @ Project(_, _: Distinct) => p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ class ColumnPruningSuite extends PlanTest {
comparePlans(optimized, expected)
}

test("Column pruning on Filter") {
test("No column pruning on Filter") {
val input = LocalRelation('a.int, 'b.string, 'c.double)
val query = Project('a :: Nil, Filter('c > Literal(0.0), input)).analyze
val expected =
Project('a :: Nil,
Filter('c > Literal(0.0),
Project(Seq('a, 'c), input))).analyze
Filter('c > Literal(0.0), input)).analyze
comparePlans(Optimize.execute(query), expected)
}

Expand Down Expand Up @@ -287,7 +286,7 @@ class ColumnPruningSuite extends PlanTest {
AggregateExpression(Count('b), Complete, isDistinct = false),
WindowSpecDefinition( 'a :: Nil,
SortOrder('b, Ascending) :: Nil,
UnspecifiedFrame)).as('window)).where('window > 1).select('a, 'c)
UnspecifiedFrame)).as('window)).select('a, 'c, 'window)

val correctAnswer =
input.select('a, 'b, 'c)
Expand All @@ -297,7 +296,7 @@ class ColumnPruningSuite extends PlanTest {
SortOrder('b, Ascending) :: Nil,
UnspecifiedFrame)).as('window) :: Nil,
'a :: Nil, 'b.asc :: Nil)
.select('a, 'c, 'window).where('window > 1).select('a, 'c).analyze
.select('a, 'c, 'window).analyze

val optimized = Optimize.execute(originalQuery.analyze)

Expand Down