aboutsummaryrefslogtreecommitdiff
path: root/sql/core
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <viirya@gmail.com>2015-04-13 18:15:29 -0700
committerMichael Armbrust <michael@databricks.com>2015-04-13 18:15:29 -0700
commit5b8b324f33e857b95de65031334846a7ca26fa60 (patch)
tree5217378a4194ccc9414f07adc2df278e334812d6 /sql/core
parentd7f2c198678d1f5ffc1c6da3a6fb189b0a4ef070 (diff)
downloadspark-5b8b324f33e857b95de65031334846a7ca26fa60.tar.gz
spark-5b8b324f33e857b95de65031334846a7ca26fa60.tar.bz2
spark-5b8b324f33e857b95de65031334846a7ca26fa60.zip
[SPARK-6303][SQL] Remove unnecessary Average in GeneratedAggregate
Because `Average` is a `PartialAggregate`, we never get a `Average` node when reaching `HashAggregation` to prepare `GeneratedAggregate`. That is why in SQLQuerySuite there is already a test for `avg` with codegen. And it works. But we can find a case in `GeneratedAggregate` to deal with `Average`. Based on the above, we actually never execute this case. So we can remove this case from `GeneratedAggregate`. Author: Liang-Chi Hsieh <viirya@gmail.com> Closes #4996 from viirya/add_average_codegened and squashes the following commits: 621c12f [Liang-Chi Hsieh] Merge remote-tracking branch 'upstream/master' into add_average_codegened 368cfbc [Liang-Chi Hsieh] Merge remote-tracking branch 'upstream/master' into add_average_codegened 74926d1 [Liang-Chi Hsieh] Add Average in canBeCodeGened lists.
Diffstat (limited to 'sql/core')
-rw-r--r--sql/core/src/main/scala/org/apache/spark/sql/execution/GeneratedAggregate.scala45
1 files changed, 0 insertions, 45 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/GeneratedAggregate.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/GeneratedAggregate.scala
index 95176e4251..b510cf033c 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/GeneratedAggregate.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/GeneratedAggregate.scala
@@ -153,51 +153,6 @@ case class GeneratedAggregate(
AggregateEvaluation(currentSum :: Nil, initialValue :: Nil, updateFunction :: Nil, result)
- case a @ Average(expr) =>
- val calcType =
- expr.dataType match {
- case DecimalType.Fixed(_, _) =>
- DecimalType.Unlimited
- case _ =>
- expr.dataType
- }
-
- val currentCount = AttributeReference("currentCount", LongType, nullable = false)()
- val currentSum = AttributeReference("currentSum", calcType, nullable = false)()
- val initialCount = Literal(0L)
- val initialSum = Cast(Literal(0L), calcType)
-
- // If we're evaluating UnscaledValue(x), we can do Count on x directly, since its
- // UnscaledValue will be null if and only if x is null; helps with Average on decimals
- val toCount = expr match {
- case UnscaledValue(e) => e
- case _ => expr
- }
-
- val updateCount = If(IsNotNull(toCount), Add(currentCount, Literal(1L)), currentCount)
- val updateSum = Coalesce(Add(Cast(expr, calcType), currentSum) :: currentSum :: Nil)
-
- val result =
- expr.dataType match {
- case DecimalType.Fixed(_, _) =>
- If(EqualTo(currentCount, Literal(0L)),
- Literal.create(null, a.dataType),
- Cast(Divide(
- Cast(currentSum, DecimalType.Unlimited),
- Cast(currentCount, DecimalType.Unlimited)), a.dataType))
- case _ =>
- If(EqualTo(currentCount, Literal(0L)),
- Literal.create(null, a.dataType),
- Divide(Cast(currentSum, a.dataType), Cast(currentCount, a.dataType)))
- }
-
- AggregateEvaluation(
- currentCount :: currentSum :: Nil,
- initialCount :: initialSum :: Nil,
- updateCount :: updateSum :: Nil,
- result
- )
-
case m @ Max(expr) =>
val currentMax = AttributeReference("currentMax", expr.dataType, nullable = true)()
val initialValue = Literal.create(null, expr.dataType)