Skip to content

Commit

Permalink
feat: always pass a null bigquery client lib to StreamWriter (#1795)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yirutang authored Sep 22, 2022
1 parent b6b515f commit eec50c1
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit eec50c1

Please sign in to comment.