@Override
  public void evaluateGroupBatch(VectorizedRowBatch batch)
      throws HiveException {

    evaluateInputExpr(batch);

    // Determine maximum of all non-null decimal column values; maintain isGroupResultNull.

    // We do not filter when PTF is in reducer.
    Preconditions.checkState(!batch.selectedInUse);

    final int size = batch.size;
    if (size == 0) {
      return;
    }
    DecimalColumnVector decimalColVector = ((DecimalColumnVector) batch.cols[inputColumnNum]);
    if (decimalColVector.isRepeating) {

      if (decimalColVector.noNulls || !decimalColVector.isNull[0]) {
        if (isGroupResultNull) {
          max.set(decimalColVector.vector[0]);
          isGroupResultNull = false;
        } else {
          HiveDecimalWritable repeatedMax = decimalColVector.vector[0];
          if (repeatedMax.compareTo(max) == 1) {
            max.set(repeatedMax);
          }
        }
      }
    } else if (decimalColVector.noNulls) {
      HiveDecimalWritable[] vector = decimalColVector.vector;
      if (isGroupResultNull) {
        max.set(vector[0]);
        isGroupResultNull = false;
      } else {
        final HiveDecimalWritable dec = vector[0];
        if (dec.compareTo(max) == 1) {
          max.set(dec);
        }
      }
      for (int i = 1; i < size; i++) {
        final HiveDecimalWritable dec = vector[i];
        if (dec.compareTo(max) == 1) {
          max.set(dec);
        }
      }
    } else {
      boolean[] batchIsNull = decimalColVector.isNull;
      int i = 0;
      while (batchIsNull[i]) {
        if (++i >= size) {
          return;
        }
      }

      HiveDecimalWritable[] vector = decimalColVector.vector;

      final HiveDecimalWritable firstValue = vector[i++];
      if (isGroupResultNull) {
        max.set(firstValue);
        isGroupResultNull = false;
      } else if (firstValue.compareTo(max) == 1) {
        max.set(firstValue);
      }
      for (; i < size; i++) {
        if (!batchIsNull[i]) {
          final HiveDecimalWritable dec = vector[i];
          if (dec.compareTo(max) == 1) {
            max.set(dec);
          }
        }
      }
    }
  }
This class evaluates HiveDecimal max() for a PTF group.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFEvaluatorDecimalMax.java