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 @@ -537,4 +537,13 @@ class DataFrameSuite extends QueryTest {
537537 val df = TestSQLContext .createDataFrame(rowRDD, schema)
538538 df.rdd.collect()
539539 }
540+
541+ test(" SPARK-6899" ) {
542+ val originalValue = TestSQLContext .conf.codegenEnabled
543+ TestSQLContext .setConf(SQLConf .CODEGEN_ENABLED , " true" )
544+ checkAnswer(
545+ decimalData.agg(avg(' a )),
546+ Row (new java.math.BigDecimal (2.0 )))
547+ TestSQLContext .setConf(SQLConf .CODEGEN_ENABLED , originalValue.toString)
548+ }
540549}
You can’t perform that action at this time.
0 commit comments