@Test
  public void canSerializeUnions() throws SerDeException, IOException {
    String field = "{ \"name\":\"union1\", \"type\":[\"float\", \"boolean\", \"string\"," +
        " {\"type\":\"bytes\", \"logicalType\":\"decimal\", \"precision\":5, \"scale\":4}] }";
    GenericRecord r = serializeAndDeserialize(field, "union1", 424.4f);
    assertEquals(424.4f, r.get("union1"));

    r = serializeAndDeserialize(field, "union1", true);
    assertEquals(true, r.get("union1"));

    r = serializeAndDeserialize(field, "union1", "hello");
    assertEquals("hello", r.get("union1"));

    HiveDecimal dec = HiveDecimal.create("3.1415926");
    r = serializeAndDeserialize(field, "union1", AvroSerdeUtils.getBufferFromDecimal(dec, 4));
    HiveDecimal dec1 = AvroSerdeUtils.getHiveDecimalFromByteBuffer((ByteBuffer) r.get("union1"), 4);

    // For now, old class.
    HiveDecimalV1 oldDec = HiveDecimalV1.create(dec.bigDecimalValue());
    assertEquals(oldDec.setScale(4).toString(), dec1.toString());
  }
Verify that we can serialize an avro value by taking one, running it through
the deser process and then serialize it again.
serde/src/test/org/apache/hadoop/hive/serde2/avro/TestAvroSerializer.java