Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Not A Bug
-
None
-
None
-
None
-
None
Description
I have an Avro schema which I am using as part of our Apache Beam pipeline tests, and using the avro-tools-1.8.2 tool I have generated random data from the Avro schema. In the tests I am using this data with the schema, but I get the following Java exception:
org.apache.avro.AvroRuntimeException: Not a union: {"type":"record","name":"sampleArrayRecord","namespace":"gamesys.sample","fields":[{"name":"sampleArrayRecordString","type":"string"}]}
I have attached the schema and the data I've used, and the relevant stacktrace is given below:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Not a union: {"type":"record","name":"sampleArrayRecord","namespace":"gamesys.sample","fields":[{"name":"sampleArrayRecordString","type":"string"}]} (through reference chain: com.google.api.services.bigquery.model.TableRow["sampleArray"]->org.apache.avro.generic.GenericData$Array[0]->org.apache.avro.generic.GenericData$Record["schema"]->org.apache.avro.Schema$RecordSchema["types"]) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:388) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:348) at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:343) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:697) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:149) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:112) at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25) at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:633) at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:536) at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:30) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3697) at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3073) at org.apache.beam.sdk.io.gcp.bigquery.TableRowJsonCoder.encode(TableRowJsonCoder.java:49) at org.apache.beam.sdk.io.gcp.bigquery.TableRowJsonCoder.encode(TableRowJsonCoder.java:34) at org.apache.beam.sdk.util.CoderUtils.encodeToSafeStream(CoderUtils.java:93) ... 22 more Caused by: org.apache.avro.AvroRuntimeException: Not a union: {"type":"record","name":"sampleArrayRecord","namespace":"gamesys.sample","fields":[{"name":"sampleArrayRecordString","type":"string"}]} at org.apache.avro.Schema.getTypes(Schema.java:299) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:664) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689) ... 38 more
I am using the org.apache.avro:avro:1.8.1 library in the project.