public void prepareConstant() {
    final Object writableValue;
    if (constExpr != null) {
      Object constantValue = constExpr.getValue();
      TypeInfo typeInfo = constExpr.getTypeInfo();
      ObjectInspector objectInspector =
          TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo);
      Category category = typeInfo.getCategory();
      switch (category) {
      case PRIMITIVE:
        {
          PrimitiveCategory pc =
              ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory();

          // Convert from Java to Writable
          AbstractPrimitiveJavaObjectInspector primitiveJavaObjectInspector =
              PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pc);
          writableValue =
              primitiveJavaObjectInspector.getPrimitiveWritableObject(constantValue);
        }
        break;
      case STRUCT:
        {
          if (constantValue.getClass().isArray()) {
            constantValue = java.util.Arrays.asList((Object[]) constantValue);
          }

          StructObjectInspector structObjectInspector =
              (StructObjectInspector) objectInspector;
          List<? extends StructField> fields = structObjectInspector.getAllStructFieldRefs();
          List<String> fieldNames = new ArrayList<String>(fields.size());
          List<ObjectInspector> fieldObjectInspectors =
              new ArrayList<ObjectInspector>(fields.size());
          for (StructField f : fields) {
            fieldNames.add(f.getFieldName());
            fieldObjectInspectors.add(
                ObjectInspectorUtils.getStandardObjectInspector(
                    f.getFieldObjectInspector(), ObjectInspectorCopyOption.WRITABLE));
          }

          StandardConstantStructObjectInspector constantStructObjectInspector =
              ObjectInspectorFactory.getStandardConstantStructObjectInspector(
              fieldNames,
              fieldObjectInspectors,
              (List<?>) constantValue);
          writableValue =
              constantStructObjectInspector.getWritableConstantValue();
        }
        break;
      default:
        throw new RuntimeException("Unexpected category " + category);
      }
    } else {
      writableValue = null;
    }

    constObjVal = new GenericUDF.DeferredJavaObject(writableValue);
  }
Set this argument to a constant value extracted from the
expression tree.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/udf/VectorUDFArgDesc.java