private String castConstantToString(Object scalar, TypeInfo type) throws HiveException {
    if (null == scalar) {
      return null;
    }
    String typename = type.getTypeName();
    if (!(type instanceof PrimitiveTypeInfo)) {
      throw new HiveException("Unsupported type " + typename + " for cast to String");
    }
    PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
    switch (ptinfo.getPrimitiveCategory()) {
    case FLOAT:
    case DOUBLE:
    case BYTE:
    case SHORT:
    case INT:
    case LONG:
      return ((Number) scalar).toString();
    case DECIMAL:
      HiveDecimal decimalVal = (HiveDecimal) scalar;
      DecimalTypeInfo decType = (DecimalTypeInfo) type;
      return decimalVal.toFormatString(decType.getScale());
    case TIMESTAMP:
      return CastTimestampToString.getTimestampString((Timestamp) scalar);
    default:
      throw new HiveException("Unsupported type "+typename+" for cast to String");
    }
  }
Invoke special handling for expressions that can't be vectorized by regular
descriptor based lookup.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java