@Override
  public ObjectInspector initialize(ObjectInspector[] arguments)
      throws UDFArgumentException {

    if (arguments.length != 2) {
      throw new UDFArgumentException(getClass().getSimpleName() + " requires two arguments.");
    }

    // Lookup values needed for numeric arithmetic UDFs
    if (confLookupNeeded) {
      CompatLevel compatLevel = HiveCompat.getCompatLevel(SessionState.getSessionConf());
      ansiSqlArithmetic = compatLevel.ordinal() > CompatLevel.HIVE_0_12.ordinal();
      confLookupNeeded = false;
    }

    // Determine if we are dealing with a numeric or date arithmetic operation
    boolean isDateTimeOp = false;
    for (int idx = 0; idx < 2; ++idx) {
      switch (((PrimitiveObjectInspector) arguments[idx]).getPrimitiveCategory()) {
        case DATE:
        case TIMESTAMP:
        case INTERVAL_YEAR_MONTH:
        case INTERVAL_DAY_TIME:
          isDateTimeOp = true;
          break;
        default:
          break;
      }
    }

    if (isDateTimeOp) {
      arithmeticOperation = instantiateDTIUDF();
    } else {
      GenericUDFBaseNumeric numericUDF = instantiateNumericUDF();

      // Set values needed for numeric arithmetic UDFs
      numericUDF.setAnsiSqlArithmetic(ansiSqlArithmetic);
      numericUDF.setConfLookupNeeded(confLookupNeeded);
      arithmeticOperation = numericUDF;
    }

    return arithmeticOperation.initialize(arguments);
  }
Wrapper UDF that will instantiate the proper arithmetic UDF (numeric, date, etc)
depending on the argument types
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBaseArithmetic.java