Description
Attempting to serialize a Thrift union type (TUnion) with avro-thrift produces an error like the following:
org.apache.avro.AvroRuntimeException: Unknown datum type org.apache.avro.thrift.test.FooOrBar: <FooOrBar foo:foo> at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:639) at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:604) at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:151) at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:71) at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:114) at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:104) at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:66) at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:58) at org.apache.avro.thrift.TestThrift.check(TestThrift.java:83) at org.apache.avro.thrift.TestThrift.testStruct(TestThrift.java:60)
Upon investigation it appears that ThriftData#isRecord intentionally does not accept TUnion types as Avro records and so GenericData is unable to determine an Avro type for the datum. However, ThriftData#getSchema does generate an Avro record schema for Thrift union types.