@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    checkArgsSize(arguments, 2, 3);
    for (int i = 0; i < arguments.length; i++) {
      checkArgPrimitive(arguments, i);
    }
    //arg 1 has to be of timestamp type
    //arg 2 has to be an interval
    //arg 3 has to be absent or timestamp type

    timestampOI = (PrimitiveObjectInspector) arguments[0];
    intervalOI = (PrimitiveObjectInspector) arguments[1];

    if (arguments.length == 3) {
      originTsOI = (PrimitiveObjectInspector) arguments[2];
      if (!PrimitiveObjectInspectorUtils.getPrimitiveGrouping(originTsOI.getPrimitiveCategory())
          .equals(PrimitiveObjectInspectorUtils.PrimitiveGrouping.DATE_GROUP)) {
        throw new UDFArgumentException("Third arg has to be timestamp got " + originTsOI.getTypeInfo().toString());
      }
    }

    if (!PrimitiveObjectInspectorUtils.getPrimitiveGrouping(timestampOI.getPrimitiveCategory())
        .equals(PrimitiveObjectInspectorUtils.PrimitiveGrouping.DATE_GROUP)) {
      throw new UDFArgumentException("First arg has to be timestamp got " + timestampOI.getTypeInfo().toString());
    }

    if (!intervalOI.getPrimitiveCategory().equals(PrimitiveObjectInspector.PrimitiveCategory.INTERVAL_DAY_TIME)) {
      throw new UDFArgumentException("Second arg has to be interval got " + intervalOI.getTypeInfo().toString());
    }

    return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.timestampTypeInfo);
  }
Initialize this GenericUDF. This will be called once and only once per
GenericUDF instance.

@param arguments
         The ObjectInspector for the arguments
@throws UDFArgumentException
          Thrown when arguments have wrong types, wrong length, etc.
@return The ObjectInspector for the return value
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTumbledWindow.java