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
Prev Previous commit
Next Next commit
Apply minor comments
  • Loading branch information
maropu committed Aug 23, 2016
commit 69751bb5d22f9f8a5505ddbaa035f664309ce30b
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ object AggUtils {
aggregateExpressions.map(e => e.copy(mode = updateMode(e.mode)))
}

private[execution] def createPartialAggregate(operator: SparkPlan)
: (SparkPlan, SparkPlan) = operator match {
/**
* Builds new merge and map-side [[AggregateExec]]s from an input aggregate operator.
* If an aggregation needs a shuffle for satisfying its own distribution and supports partial
* aggregations, a map-side aggregation is appended before the shuffle in
* [[org.apache.spark.sql.execution.exchange.EnsureRequirements]].
*/
def createMapMergeAggregatePair(operator: SparkPlan): (SparkPlan, SparkPlan) = operator match {
case agg: AggregateExec =>
val mapSideAgg = createPartialAggregateExec(
agg.groupingExpressions, agg.aggregateExpressions, agg.child)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ case class EnsureRequirements(conf: SQLConf) extends Rule[SparkPlan] {
case PartialAggregate(childDist) if !operator.outputPartitioning.satisfies(childDist) =>
// If an aggregation needs a shuffle and support partial aggregations, a map-side partial
// aggregation and a shuffle are added as children.
val (mergeAgg, mapSideAgg) = AggUtils.createPartialAggregate(operator)
val (mergeAgg, mapSideAgg) = AggUtils.createMapMergeAggregatePair(operator)
(mergeAgg, createShuffleExchange(requiredChildDistributions.head, mapSideAgg) :: Nil)
case _ =>
// Ensure that the operator's children satisfy their output distribution requirements:
Expand Down