private void testHashAggr(GroupByOperator op, HiveConf hconf, InspectableObject[] r, int expectOutputSize)
      throws HiveException {
    // 1. Collect operator to observe the output of the group by operator
    CollectDesc cd = new CollectDesc(expectOutputSize + 10);
    CollectOperator cdop = (CollectOperator) OperatorFactory.getAndMakeChild(cd, op);
    op.initialize(hconf, new ObjectInspector[] { r[0].oi });
    // 2. Evaluate on rows and check hashAggr flag
    for (int i = 0; i < r.length; i++) {
      op.process(r[i].o, 0);
    }
    op.close(false);
    InspectableObject io = new InspectableObject();
    int output = 0;
    // 3. Print group by results
    do {
      cdop.retrieve(io);
      if (io.o != null) {
        System.out.println("io.o = " + io.o);
        output++;
      }
    } while (io.o != null);
    // 4. Check partial result size
    assertEquals(expectOutputSize, output);
  }
A custom input format that checks to make sure that the fetch operator
sets the required attributes.
ql/src/test/org/apache/hadoop/hive/ql/exec/TestOperators.java