File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions
core/src/test/scala/org/apache/spark/sql Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -326,7 +326,7 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN
326326
327327 override def asPartial : SplitEvaluation = {
328328 child.dataType match {
329- case DecimalType .Fixed (_, _) =>
329+ case DecimalType .Fixed (_, _) | DecimalType . Unlimited =>
330330 // Turn the child to unlimited decimals for calculation, before going back to fixed
331331 val partialSum = Alias (Sum (Cast (child, DecimalType .Unlimited )), " PartialSum" )()
332332 val partialCount = Alias (Count (child), " PartialCount" )()
Original file line number Diff line number Diff line change @@ -531,4 +531,13 @@ class DataFrameSuite extends QueryTest {
531531 val df = TestSQLContext .createDataFrame(rowRDD, schema)
532532 df.rdd.collect()
533533 }
534+
535+ test(" SPARK-6899" ) {
536+ val originalValue = TestSQLContext .conf.codegenEnabled
537+ TestSQLContext .setConf(SQLConf .CODEGEN_ENABLED , " true" )
538+ checkAnswer(
539+ decimalData.agg(avg(' a )),
540+ Row (new java.math.BigDecimal (2.0 )))
541+ TestSQLContext .setConf(SQLConf .CODEGEN_ENABLED , originalValue.toString)
542+ }
534543}
You can’t perform that action at this time.
0 commit comments