@@ -26,7 +26,7 @@ import org.apache.spark.sql.catalyst.plans._
2626import org .apache .spark .sql .catalyst .plans .logical .{BroadcastHint , LogicalPlan }
2727import org .apache .spark .sql .catalyst .plans .physical ._
2828import org .apache .spark .sql .columnar .{InMemoryColumnarTableScan , InMemoryRelation }
29- import org .apache .spark .sql .execution .{DescribeCommand => RunnableDescribeCommand , aggregate }
29+ import org .apache .spark .sql .execution .{DescribeCommand => RunnableDescribeCommand }
3030import org .apache .spark .sql .execution .datasources .{CreateTableUsing , CreateTempTableUsing , DescribeCommand => LogicalDescribeCommand , _ }
3131import org .apache .spark .sql .parquet ._
3232import org .apache .spark .sql .types ._
@@ -409,9 +409,21 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
409409 execution.Filter (condition, planLater(child)) :: Nil
410410 case e @ logical.Expand (_, _, _, child) =>
411411 execution.Expand (e.projections, e.output, planLater(child)) :: Nil
412- case a @ logical.Aggregate (group, agg, child)
413- if ! aggregate.Utils .tryConvert(a, sqlContext.conf.useSqlAggregate2).isDefined =>
414- execution.Aggregate (partial = false , group, agg, planLater(child)) :: Nil
412+ case a @ logical.Aggregate (group, agg, child) => {
413+ val useNewAggregation =
414+ aggregate.Utils .tryConvert(
415+ a,
416+ sqlContext.conf.useSqlAggregate2,
417+ sqlContext.conf.codegenEnabled).isDefined
418+ if (useNewAggregation) {
419+ // If this logical.Aggregate can be planned to use new aggregation code path
420+ // (i.e. it can be planned by the Strategy Aggregation), we will not use the old
421+ // aggregation code path.
422+ Nil
423+ } else {
424+ execution.Aggregate (partial = false , group, agg, planLater(child)) :: Nil
425+ }
426+ }
415427 case logical.Window (projectList, windowExpressions, spec, child) =>
416428 execution.Window (projectList, windowExpressions, spec, planLater(child)) :: Nil
417429 case logical.Sample (lb, ub, withReplacement, seed, child) =>
0 commit comments