public static TypeInfo getDecimalTypeForPrimitiveCategories(
      PrimitiveTypeInfo a, PrimitiveTypeInfo b) {
    int prec1 = HiveDecimalUtils.getPrecisionForType(a);
    int prec2 = HiveDecimalUtils.getPrecisionForType(b);
    int scale1 = HiveDecimalUtils.getScaleForType(a);
    int scale2 = HiveDecimalUtils.getScaleForType(b);
    int intPart = Math.max(prec1 - scale1, prec2 - scale2);
    int decPart = Math.max(scale1, scale2);
    int prec =  Math.min(intPart + decPart, HiveDecimal.MAX_PRECISION);
    int scale = Math.min(decPart, HiveDecimal.MAX_PRECISION - intPart);
    return TypeInfoFactory.getDecimalTypeInfo(prec, scale);
  }
Need to keep consistent with JdbcColumn.columnScale()
serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/HiveDecimalUtils.java