private static boolean isNonVectorizedPathUDF(ExprNodeGenericFuncDesc expr,
      VectorExpressionDescriptor.Mode mode) {
    GenericUDF gudf = expr.getGenericUDF();
    if (gudf instanceof GenericUDFBridge) {
      GenericUDFBridge bridge = (GenericUDFBridge) gudf;
      Class<? extends UDF> udfClass = bridge.getUdfClass();
      return udfClass.equals(UDFHex.class)
          || udfClass.equals(UDFRegExpExtract.class)
          || udfClass.equals(UDFRegExpReplace.class)
          || udfClass.equals(UDFConv.class)
          || isCastToIntFamily(udfClass) && isStringFamily(arg0Type(expr))
          || isCastToFloatFamily(udfClass) && isStringFamily(arg0Type(expr));
    } else if (gudf instanceof GenericUDFFromUnixTime && isIntFamily(arg0Type(expr))
          || (gudf instanceof GenericUDFTimestamp && isStringFamily(arg0Type(expr)))

            /* GenericUDFWhen is implemented with the UDF Adaptor because
             * of its complexity and generality. In the future, variations of this
             * can be optimized to run faster for the vectorized code path. For example,
             * CASE col WHEN 1 then "one" WHEN 2 THEN "two" ELSE "other" END
             * is an example when all constant arguments
             * except for the first argument. This is probably a common case and a
             * good candidate for a fast, special-purpose VectorExpression. Then
             * the UDF Adaptor code path could be used as a catch-all for
             * non-optimized general cases.
             */
            || gudf instanceof GenericUDFWhen) {
      return true;
    } else // between has 4 args here, but can be vectorized like this
      if ((gudf instanceof GenericUDFToString
                   || gudf instanceof GenericUDFToChar
                   || gudf instanceof GenericUDFToVarchar) &&
               (arg0Type(expr).equals(serdeConstants.TIMESTAMP_TYPE_NAME)
                   || arg0Type(expr).equals(serdeConstants.DOUBLE_TYPE_NAME)
                   || arg0Type(expr).equals(serdeConstants.FLOAT_TYPE_NAME))) {
      return true;
    } else if (gudf instanceof GenericUDFBetween && (mode == VectorExpressionDescriptor.Mode.PROJECTION)) {
      return true;
    } else if (gudf instanceof GenericUDFConcat && (mode == VectorExpressionDescriptor.Mode.PROJECTION)) {
      return true;
    }
    return false;
  }
The GenericUDFs might need their children output to be cast to the given castType.
This method returns a cast expression that would achieve the required casting.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java