@Override
  protected void func(DecimalColumnVector outV, DoubleColumnVector inV, int i) {
    HiveDecimalWritable decWritable = outV.vector[i];
    decWritable.setFromDouble(inV.vector[i]);
    if (!decWritable.mutateEnforcePrecisionScale(outV.precision, outV.scale)) {
      outV.isNull[i] = true;
      outV.noNulls = false;
    }
  }
Cast input double to a decimal. Get target value scale from output column vector.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/CastDoubleToDecimal.java