For local development and integration testing, I am using a BigQuery emulator that exposes ports 9050 (for HTTP) and 9060 (for grpc). For example, this is how I instantiate BigQuery client object in Java (this works and it is connecting to my emulator):
BigQuery bigQuery = BigQueryOptions.newBuilder()
.setProjectId(BQ_PROJECT)
.setHost("http://localhost:9050")
.build().getService();
Now, I need to do the same thing for a JsonStreamWriter. Unfortunately, I couldn't find a way to do it and from the documentation, it's unclear how to do it.
I have tried instantiating the JsonStreamWriter in many different ways, but with no success:
JsonStreamWriter streamWriter = JsonStreamWriter.newBuilder(
TableName.of(BQ_PROJECT, BQ_DATASET, BQ_TABLE).toString(),
BigQueryWriteClient.create(
BigQueryWriteSettings.newBuilder()
.setEndpoint("localhost:9060")
.build()
)
)
.build();
No matter what I try, it always gets stuck when calling the build() method. does anybody know what is not working or what else I should be doing/trying?
Can you try this sample found here? (It has also a bit of description provided in the comments)
You can also find other functions as well in this github library: https://github.com/googleapis/java-bigquerystorage/blob/main/samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java