@Override
  public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo parameters)
          throws SemanticException {

    ObjectInspector[] paramOIs = parameters.getParameterObjectInspectors();
    String fNm = functionName();

    if (!(paramOIs.length >= 1 && paramOIs.length <= 3)) {
      throw new UDFArgumentTypeException(paramOIs.length - 1, "Incorrect invocation of " + fNm
              + ": _FUNC_(expr, amt, default)");
    }

    int amt = 1;
    if (paramOIs.length > 1) {
      ObjectInspector amtOI = paramOIs[1];

      if (!ObjectInspectorUtils.isConstantObjectInspector(amtOI)
              || (amtOI.getCategory() != ObjectInspector.Category.PRIMITIVE)
              || ((PrimitiveObjectInspector) amtOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.INT) {
        throw new UDFArgumentTypeException(1, fNm + " amount must be a integer value "
                + amtOI.getTypeName() + " was passed as parameter 1.");
      }
      Object o = ((ConstantObjectInspector) amtOI).getWritableConstantValue();
      amt = ((IntWritable) o).get();
      if (amt < 0) {
        throw new UDFArgumentTypeException(1, fNm + " amount can not be negative. Specified: " + amt );
      }
    }

    if (paramOIs.length == 3) {
      ObjectInspectorConverters.getConverter(paramOIs[2], paramOIs[0]);
    }

    GenericUDAFLeadLagEvaluator eval = createLLEvaluator();
    eval.setAmt(amt);
    return eval;
  }
abstract class for Lead &amp; lag UDAFs GenericUDAFLeadLag.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFLeadLag.java