diff --git a/velox/functions/sparksql/aggregates/DecimalSumAggregate.h b/velox/functions/sparksql/aggregates/DecimalSumAggregate.h index d5aa9a698d992..2ea6561f66089 100644 --- a/velox/functions/sparksql/aggregates/DecimalSumAggregate.h +++ b/velox/functions/sparksql/aggregates/DecimalSumAggregate.h @@ -72,7 +72,7 @@ class DecimalSumAggregate : public exec::Aggregate { auto [resultPrecision, resultScale] = getDecimalPrecisionScale(*sumType_.get()); - overflow = !DecimalUtil::valueInRangeWithPrecision(sum, resultPrecision); + overflow = !DecimalUtil::valueInPrecisionRange(sum, resultPrecision); return sum; } @@ -131,7 +131,8 @@ class DecimalSumAggregate : public exec::Aggregate { for (auto i = 0; i < numGroups; ++i) { char* group = groups[i]; if (isNull(group)) { - rowVector->setNull(i, true); + rawSums[i] = 0; + bits::setBit(rawIsEmpty, i, true); } else { clearNull(rawNulls, i); auto* decimalSum = accumulator(group);