Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-7267][SQL]Push down Project when it's child is Limit #5797

Closed
wants to merge 14 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ object ColumnPruning extends Rule[LogicalPlan] {

Project(substitutedProjection, child)

case Project(projectList, Limit(exp, child)) =>
Limit(exp, Project(projectList, child))

// Eliminate no-op Projects
case Project(projectList, child) if child.output == projectList => child
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,23 @@ class FilterPushdownSuite extends PlanTest {

comparePlans(optimized, correctAnswer)
}

test("column pruning for Project(ne, Limit)") {
val originalQuery =
testRelation
.select('a,'b)
.limit(2)
.select('a)

val optimized = Optimize.execute(originalQuery.analyze)
val correctAnswer =
testRelation
.select('a)
.limit(2).analyze

comparePlans(optimized, correctAnswer)
}

// After this line is unimplemented.
test("simple push down") {
val originalQuery =
Expand Down