File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
main/scala/org/apache/spark/sql/catalyst/optimizer
test/scala/org/apache/spark/sql/catalyst/optimizer Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,9 @@ object ColumnPruning extends Rule[LogicalPlan] {
170170
171171 Project (substitutedProjection, child)
172172
173+ case Project (projectList, Limit (exp, child)) =>
174+ Limit (exp, Project (projectList, child))
175+
173176 // Eliminate no-op Projects
174177 case Project (projectList, child) if child.output == projectList => child
175178 }
Original file line number Diff line number Diff line change @@ -90,7 +90,23 @@ class FilterPushdownSuite extends PlanTest {
9090
9191 comparePlans(optimized, correctAnswer)
9292 }
93+
94+ test(" column pruning for Project(ne, Limit)" ) {
95+ val originalQuery =
96+ testRelation
97+ .select(' a ,' b )
98+ .limit(2 )
99+ .select(' a )
100+
101+ val optimized = Optimize .execute(originalQuery.analyze)
102+ val correctAnswer =
103+ testRelation
104+ .select(' a )
105+ .limit(2 ).analyze
93106
107+ comparePlans(optimized, correctAnswer)
108+ }
109+
94110 // After this line is unimplemented.
95111 test(" simple push down" ) {
96112 val originalQuery =
You can’t perform that action at this time.
0 commit comments