From eec50c14e1dff84ae9a3e70f9d08d27b9e225e55 Mon Sep 17 00:00:00 2001 From: Yiru Tang Date: Thu, 22 Sep 2022 16:48:18 -0700 Subject: [PATCH] feat: always pass a null bigquery client lib to StreamWriter (#1795) In order for regional routing to work, right now, we need to recreate a BigQueryWriteClient with custom header on StreamWriter. The new JsonWriter builder interface we added requires a not null BigQueryClient in order to be able to call GetWriteStream, if the user always pass in BigQueryWriteClient, in the current code, we reuses that BigQueryWriteClient and then the customer header will not be added and routing will fail. So no matter whether we have an existing BigQueryWriteClient or not on the json writer, we always ask StreamWriter to create a new BigQueryWriteClient in order for routing to work. We are working on the backend to make this special workaround no longer needed. --- .../google/cloud/bigquery/storage/v1/JsonStreamWriter.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriter.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriter.java index e6892475a6..6ef655781b 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriter.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriter.java @@ -73,11 +73,7 @@ private JsonStreamWriter(Builder builder) this.descriptor = BQTableSchemaToProtoDescriptor.convertBQTableSchemaToProtoDescriptor(builder.tableSchema); - if (this.client == null) { - streamWriterBuilder = StreamWriter.newBuilder(builder.streamName); - } else { - streamWriterBuilder = StreamWriter.newBuilder(builder.streamName, builder.client); - } + streamWriterBuilder = StreamWriter.newBuilder(builder.streamName); this.protoSchema = ProtoSchemaConverter.convert(this.descriptor); this.totalMessageSize = protoSchema.getSerializedSize(); streamWriterBuilder.setWriterSchema(protoSchema);