@Override
    public Object terminate(AggregationBuffer agg) throws HiveException {
      return ((LeadLagBuffer) agg).terminate();
    }
abstract class for Lead &amp; lag UDAFs GenericUDAFLeadLag.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFLeadLag.java