Skip to content

Commit b69d385

Browse files
committed
add a prune rule for grouping set
1 parent 1c8633f commit b69d385

File tree

1 file changed

+4
-0
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ object ColumnPruning extends Rule[LogicalPlan] {
119119
case a @ Aggregate(_, _, child) if (child.outputSet -- a.references).nonEmpty =>
120120
a.copy(child = Project(a.references.toSeq, child))
121121

122+
case p @ Project(_, Aggregate(ge, ec, child))
123+
if (ec.map(_.references).toSet -- p.references).nonEmpty =>
124+
Aggregate(ge, ec.filter(e => p.references.contains(e)), child)
125+
122126
// Eliminate unneeded attributes from either side of a Join.
123127
case Project(projectList, Join(left, right, joinType, condition)) =>
124128
// Collect the list of all references required either above or to evaluate the condition.

0 commit comments

Comments
 (0)