private static boolean isConstantFoldableUdf(GenericUDF udf,  List<ExprNodeDesc> children) {
    // Runtime constants + deterministic functions can be folded.
    if (!FunctionRegistry.isConsistentWithinQuery(udf)) {
      if (udf.getClass().equals(GenericUDFUnixTimeStamp.class)
          && children != null && children.size() > 0) {
        // unix_timestamp is polymorphic (ignore class annotations)
        return true;
      }
      return false;
    }

    // If udf is requiring additional jars, we can't determine the result in
    // compile time.
    String[] files;
    String[] jars;
    if (udf instanceof GenericUDFBridge) {
      GenericUDFBridge bridge = (GenericUDFBridge) udf;
      String udfClassName = bridge.getUdfClassName();
      try {
        UDF udfInternal =
            (UDF) Class.forName(bridge.getUdfClassName(), true, Utilities.getSessionSpecifiedClassLoader())
                .newInstance();
        files = udfInternal.getRequiredFiles();
        jars = udfInternal.getRequiredJars();
      } catch (Exception e) {
        LOG.error("The UDF implementation class '" + udfClassName
            + "' is not present in the class path");
        return false;
      }
    } else {
      files = udf.getRequiredFiles();
      jars = udf.getRequiredJars();
    }
    if (files != null || jars != null) {
      return false;
    }
    return true;
  }
Can the UDF be used for constant folding.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java