public static DecimalTypeInfo deriveSumFieldTypeInfo(int precision, int scale) {
    int intPart = precision - scale;
    intPart = Math.min(intPart + 10, HiveDecimal.MAX_PRECISION - scale);
    return TypeInfoFactory.getDecimalTypeInfo(intPart + scale, scale);
  }
The intermediate sum field has 10 more integer digits with the same scale.
This is exposed as static so that the vectorized AVG operator use the same logic
@param precision
@param scale
@return
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFAverage.java