Skip to content

Commit 085140a

Browse files
Use Avro 1.8-compatible Schema constructors in Storage Write API translator (#34281)
* Use Schema builder APIs compatible with Avro 1.8 in Storage Write API translator * Suppress nullness check * Update CHANGES.md
1 parent 56409b2 commit 085140a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
* (Python) Fixed occasional pipeline stuckness that was affecting Python 3.11 users ([#33966](https://github.com/apache/beam/issues/33966)).
9191
* (Java) Fixed TIME field encodings for BigQuery Storage API writes on GenericRecords ([#34059](https://github.com/apache/beam/pull/34059)).
9292
* (Java) Fixed a race condition in JdbcIO which could cause hangs trying to acquire a connection ([#34058](https://github.com/apache/beam/pull/34058)).
93+
* (Java) Fix BigQuery Storage Write compatibility with Avro 1.8 ([#34281](https://github.com/apache/beam/pull/34281)).
9394

9495
## Security Fixes
9596
* Fixed (CVE-YYYY-NNNN)[https://www.cve.org/CVERecord?id=CVE-YYYY-NNNN] (Java/Python/Go) ([#X](https://github.com/apache/beam/issues/X)).

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ public static DynamicMessage messageFromGenericRecord(
311311
return builder.build();
312312
}
313313

314+
@SuppressWarnings("nullness")
314315
private static TableFieldSchema fieldDescriptorFromAvroField(org.apache.avro.Schema.Field field) {
315316
@Nullable Schema schema = field.schema();
316317
Preconditions.checkNotNull(schema, "Unexpected null schema!");
@@ -350,10 +351,11 @@ private static TableFieldSchema fieldDescriptorFromAvroField(org.apache.avro.Sch
350351
throw new RuntimeException("Unexpected null element type!");
351352
}
352353
TableFieldSchema keyFieldSchema =
353-
fieldDescriptorFromAvroField(new Schema.Field("key", keyType, "key of the map entry"));
354+
fieldDescriptorFromAvroField(
355+
new Schema.Field("key", keyType, "key of the map entry", null));
354356
TableFieldSchema valueFieldSchema =
355357
fieldDescriptorFromAvroField(
356-
new Schema.Field("value", valueType, "value of the map entry"));
358+
new Schema.Field("value", valueType, "value of the map entry", null));
357359
builder =
358360
builder
359361
.setType(TableFieldSchema.Type.STRUCT)
@@ -371,7 +373,8 @@ private static TableFieldSchema fieldDescriptorFromAvroField(org.apache.avro.Sch
371373
elementType.getType() != Schema.Type.UNION,
372374
"Multiple non-null union types are not supported.");
373375
TableFieldSchema unionFieldSchema =
374-
fieldDescriptorFromAvroField(new Schema.Field(field.name(), elementType, field.doc()));
376+
fieldDescriptorFromAvroField(
377+
new Schema.Field(field.name(), elementType, field.doc(), null));
375378
builder =
376379
builder
377380
.setType(unionFieldSchema.getType())

0 commit comments

Comments
 (0)