public static void assertResults(Operator<SelectDesc> selectOp, CollectOperator collectOp,
      InspectableObject [] sourceData, InspectableObject [] expected) throws HiveException {
    InspectableObject resultRef = new InspectableObject();
    for (int i = 0; i < sourceData.length; i++) {
      selectOp.process(sourceData[i].o, 0);
      collectOp.retrieve(resultRef);
      StructObjectInspector expectedOi = (StructObjectInspector) expected[i].oi;
      List<? extends StructField> expectedFields = expectedOi.getAllStructFieldRefs();
      StructObjectInspector destinationOi = (StructObjectInspector) resultRef.oi;
      List<? extends StructField> destinationFields = destinationOi.getAllStructFieldRefs();
      Assert.assertEquals("Source and destination have differing numbers of fields ", expectedFields.size(), destinationFields.size());
      for (StructField field : expectedFields){
        StructField dest = expectedOi.getStructFieldRef(field.getFieldName());
        Assert.assertNotNull("Cound not find column named "+field.getFieldName(), dest);
        Assert.assertEquals(field.getFieldObjectInspector(), dest.getFieldObjectInspector());
        Assert.assertEquals("comparing " +
            expectedOi.getStructFieldData(expected[i].o, field)+" "+
            field.getFieldObjectInspector().getClass().getSimpleName()+" to "+
            destinationOi.getStructFieldData(resultRef.o, dest) + " " +
            dest.getFieldObjectInspector().getClass().getSimpleName(), 0,
            ObjectInspectorUtils.compare(
            expectedOi.getStructFieldData(expected[i].o, field), field.getFieldObjectInspector(),
            destinationOi.getStructFieldData(resultRef.o, dest), dest.getFieldObjectInspector()
            )
        );
      }

    }
    selectOp.close(false);
  }
Given a select operator and a collectOperator feed the sourceData into the operator
tree and assert that each row matches the expectedResult
@param selectOp
@param collectOp
@param sourceData
@param expected
@throws HiveException
ql/src/test/org/apache/hadoop/hive/ql/testutil/OperatorTestUtils.java