private void testShorterSchemaDeserialization1(Random r) throws Throwable {

    StructObjectInspector rowOI1 = (StructObjectInspector) ObjectInspectorFactory
        .getReflectionObjectInspector(MyTestClass.class,
        ObjectInspectorOptions.JAVA);
    String fieldNames1 = ObjectInspectorUtils.getFieldNames(rowOI1);
    String fieldTypes1 = ObjectInspectorUtils.getFieldTypes(rowOI1);
    AbstractSerDe serde1 = getSerDe(fieldNames1, fieldTypes1);
    serde1.getObjectInspector();

    StructObjectInspector rowOI2 = (StructObjectInspector) ObjectInspectorFactory
        .getReflectionObjectInspector(MyTestClassSmaller.class,
        ObjectInspectorOptions.JAVA);
    String fieldNames2 = ObjectInspectorUtils.getFieldNames(rowOI2);
    String fieldTypes2 = ObjectInspectorUtils.getFieldTypes(rowOI2);
    AbstractSerDe serde2 = getSerDe(fieldNames2, fieldTypes2);
    ObjectInspector serdeOI2 = serde2.getObjectInspector();

    int num = 100;
    for (int itest = 0; itest < num; itest++) {
      MyTestClass t = new MyTestClass();
      ExtraTypeInfo extraTypeInfo = new ExtraTypeInfo();
      t.randomFill(r, extraTypeInfo);
      BytesWritable bw = (BytesWritable) serde1.serialize(t, rowOI1);
      Object output = serde2.deserialize(bw);

      if (0 != compareDiffSizedStructs(t, rowOI1, output, serdeOI2)) {
        System.out.println("structs      = "
            + SerDeUtils.getJSONString(t, rowOI1));
        System.out.println("deserialized = "
            + SerDeUtils.getJSONString(output, serdeOI2));
        System.out.println("serialized   = "
            + TestBinarySortableSerDe.hexString(bw));
        assertEquals(t, output);
      }
    }
  }
Test shorter schema deserialization where a bigger struct is serialized and
it is then deserialized with a smaller struct. Here the serialized struct
has 9 fields and we deserialized to a struct of 8 fields.
serde/src/test/org/apache/hadoop/hive/serde2/lazybinary/TestLazyBinarySerDe.java