@Test
public void testGetBagSubSchema() throws Exception {

  // Define the expected schema.
  ResourceFieldSchema[] bagSubFieldSchemas = new ResourceFieldSchema[1];
  bagSubFieldSchemas[0] = new ResourceFieldSchema().setName("innertuple")
    .setDescription("The tuple in the bag").setType(DataType.TUPLE);
  ResourceFieldSchema[] innerTupleFieldSchemas = new ResourceFieldSchema[1];
  innerTupleFieldSchemas[0] =
    new ResourceFieldSchema().setName("innerfield").setType(DataType.CHARARRAY);
  bagSubFieldSchemas[0].setSchema(new ResourceSchema().setFields(innerTupleFieldSchemas));
  ResourceSchema expected = new ResourceSchema().setFields(bagSubFieldSchemas);
  // Get the actual converted schema.
  HCatSchema hCatSchema = new HCatSchema(Lists.newArrayList(
    new HCatFieldSchema("innerLlama", HCatFieldSchema.Type.STRING, null)));
  HCatFieldSchema hCatFieldSchema =
    new HCatFieldSchema("llama", HCatFieldSchema.Type.ARRAY, hCatSchema, null);
  ResourceSchema actual = PigHCatUtil.getBagSubSchema(hCatFieldSchema);
  Assert.assertEquals(expected.toString(), actual.toString());
}