Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN

override def asPartial: SplitEvaluation = {
child.dataType match {
case DecimalType.Fixed(_, _) =>
case DecimalType.Fixed(_, _) | DecimalType.Unlimited =>
// Turn the child to unlimited decimals for calculation, before going back to fixed
val partialSum = Alias(Sum(Cast(child, DecimalType.Unlimited)), "PartialSum")()
val partialCount = Alias(Count(child), "PartialCount")()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,13 @@ class DataFrameSuite extends QueryTest {
val df = TestSQLContext.createDataFrame(rowRDD, schema)
df.rdd.collect()
}

test("SPARK-6899") {
val originalValue = TestSQLContext.conf.codegenEnabled
TestSQLContext.setConf(SQLConf.CODEGEN_ENABLED, "true")
checkAnswer(
decimalData.agg(avg('a)),
Row(new java.math.BigDecimal(2.0)))
TestSQLContext.setConf(SQLConf.CODEGEN_ENABLED, originalValue.toString)
}
}