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

    evaluateInputExpr(batch);

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

    // 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]);

    DecimalColumnVector outputColVector = (DecimalColumnVector) batch.cols[outputColumnNum];

    if (decimalColVector.isRepeating) {

      if (decimalColVector.noNulls || !decimalColVector.isNull[0]) {

        HiveDecimalWritable repeatedMax = decimalColVector.vector[0];
        if (isNull) {
          max.set(repeatedMax);
          isNull = false;
        } else if (repeatedMax.compareTo(max) == 1) {
          max.set(repeatedMax);
        }
        outputColVector.set(0, max);
      } else if (isNull) {
        outputColVector.isNull[0] = true;
        outputColVector.noNulls = false;
      } else {

        // Continue previous MAX.
        outputColVector.set(0, max);
      }
      outputColVector.isRepeating = true;
    } else if (decimalColVector.noNulls) {
      HiveDecimalWritable[] vector = decimalColVector.vector;
      for (int i = 0; i < size; i++) {
        final HiveDecimalWritable value = vector[i];
        if (isNull) {
          max.set(value);
          isNull = false;
        } else if (value.compareTo(max) == 1) {
          max.set(value);
        }
        outputColVector.set(i, max);
      }
    } else {
      boolean[] batchIsNull = decimalColVector.isNull;
      int i = 0;
      while (batchIsNull[i]) {
        if (isNull) {
          outputColVector.isNull[i] = true;
          outputColVector.noNulls = false;
        } else {

          // Continue previous MAX.
          outputColVector.set(i, max);
        }
        if (++i >= size) {
          return;
        }
      }

      HiveDecimalWritable[] vector = decimalColVector.vector;

      final HiveDecimalWritable firstValue = vector[i];
      if (isNull) {
        max.set(firstValue);
        isNull = false;
      } else if (firstValue.compareTo(max) == 1) {
        max.set(firstValue);
      }

      outputColVector.set(i++, max);

      for (; i < size; i++) {
        if (!batchIsNull[i]) {
          final HiveDecimalWritable value = vector[i];
          if (isNull) {
            max.set(value);
            isNull = false;
          } else if (value.compareTo(max) == 1) {
            max.set(value);
          }
          outputColVector.set(i, max);
        } else {

          // Continue previous MAX.
          outputColVector.set(i, max);
        }
      }
    }
  }
This class evaluates HiveDecimal max() for a PTF group.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFEvaluatorStreamingDecimalMax.java