public HiveDecimalWritable getWritableConstantValue() {
// We need to enforce precision/scale here.
// A little inefficiency here as we need to create a HiveDecimal instance from the writable and
// recreate a HiveDecimalWritable instance on the HiveDecimal instance. However, we don't know
// the precision/scale of the original writable until we get a HiveDecimal instance from it.
DecimalTypeInfo decTypeInfo = (DecimalTypeInfo)typeInfo;
HiveDecimal dec = value == null ? null :
value.getHiveDecimal(decTypeInfo.precision(), decTypeInfo.scale());
if (dec == null) {
return null;
}
return new HiveDecimalWritable(dec);
}