private Object deserializeUnion(Object datum, Schema fileSchema, Schema recordSchema,
                                  UnionTypeInfo columnType) throws AvroSerdeException {
    // Calculate tags individually since the schema can evolve and can have different tags. In worst case, both schemas are same
    // and we would end up doing calculations twice to get the same tag
    int fsTag = GenericData.get().resolveUnion(fileSchema, datum); // Determine index of value from fileSchema
    int rsTag = GenericData.get().resolveUnion(recordSchema, datum); // Determine index of value from recordSchema
    Object desired = worker(datum, fileSchema == null ? null : fileSchema.getTypes().get(fsTag),
        recordSchema.getTypes().get(rsTag), columnType.getAllUnionObjectTypeInfos().get(rsTag));
    return new StandardUnionObjectInspector.StandardUnion((byte)rsTag, desired);
  }
Deserialize an Avro record, recursing into its component fields and
deserializing them as well.  Fields of the record are matched by name
against fields in the Hive row.

Because Avro has some data types that Hive does not, these are converted
during deserialization to types Hive will work with.

@param columnNames List of columns Hive is expecting from record.
@param columnTypes List of column types matched by index to names
@param writable Instance of GenericAvroWritable to deserialize
@param readerSchema Schema of the writable to deserialize
@return A list of objects suitable for Hive to work with further
@throws AvroSerdeException For any exception during deserialization
serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroDeserializer.java