diff --git a/CHANGES.md b/CHANGES.md index c75a42d25945..b7b86b2313e9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -88,6 +88,7 @@ * (Python) Fixed occasional pipeline stuckness that was affecting Python 3.11 users ([#33966](https://github.com/apache/beam/issues/33966)). * (Java) Fixed TIME field encodings for BigQuery Storage API writes on GenericRecords ([#34059](https://github.com/apache/beam/pull/34059)). * (Java) Fixed a race condition in JdbcIO which could cause hangs trying to acquire a connection ([#34058](https://github.com/apache/beam/pull/34058)). +* (Java) Fix BigQuery Storage Write compatibility with Avro 1.8 ([#34281](https://github.com/apache/beam/pull/34281)). ## Security Fixes * Fixed (CVE-YYYY-NNNN)[https://www.cve.org/CVERecord?id=CVE-YYYY-NNNN] (Java/Python/Go) ([#X](https://github.com/apache/beam/issues/X)). diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java index 3813b000a65b..fd9dffc260e7 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java @@ -311,6 +311,7 @@ public static DynamicMessage messageFromGenericRecord( return builder.build(); } + @SuppressWarnings("nullness") private static TableFieldSchema fieldDescriptorFromAvroField(org.apache.avro.Schema.Field field) { @Nullable Schema schema = field.schema(); Preconditions.checkNotNull(schema, "Unexpected null schema!"); @@ -350,10 +351,11 @@ private static TableFieldSchema fieldDescriptorFromAvroField(org.apache.avro.Sch throw new RuntimeException("Unexpected null element type!"); } TableFieldSchema keyFieldSchema = - fieldDescriptorFromAvroField(new Schema.Field("key", keyType, "key of the map entry")); + fieldDescriptorFromAvroField( + new Schema.Field("key", keyType, "key of the map entry", null)); TableFieldSchema valueFieldSchema = fieldDescriptorFromAvroField( - new Schema.Field("value", valueType, "value of the map entry")); + new Schema.Field("value", valueType, "value of the map entry", null)); builder = builder .setType(TableFieldSchema.Type.STRUCT) @@ -371,7 +373,8 @@ private static TableFieldSchema fieldDescriptorFromAvroField(org.apache.avro.Sch elementType.getType() != Schema.Type.UNION, "Multiple non-null union types are not supported."); TableFieldSchema unionFieldSchema = - fieldDescriptorFromAvroField(new Schema.Field(field.name(), elementType, field.doc())); + fieldDescriptorFromAvroField( + new Schema.Field(field.name(), elementType, field.doc(), null)); builder = builder .setType(unionFieldSchema.getType())