googleapis / googleapis/google-cloud-java

[java-bigquery] Improve documentation: It's unclear how to conenct to a local emulator

Abierto
#12,160 4 comentarios 3 reacciones 1 asignado Reclamado por @agrawal-siddharth Ver en GitHub
api: bigquery priority: p3
Lenguaje dominante
Java
Estrellas
2.1k
Forks
1.2k
Merge medio
1 d 23 h
PR fusionados (30 d)
154

Descripción

We are testing the interaction with BigQuery using Testcontainers and their [glcoud module](https://java.testcontainers.org/modules/gcloud/).
Internally, this will use the [BigQuery emulator from goccy](https://github.com/goccy/bigquery-emulator).

Although everything is ok for the REST Api and we can test everything related to it using this setup, setting up a [JsonStreamWriter](https://cloud.google.com/bigquery/docs/write-api-streaming) that connects to the emulator via grpc it's pretty hard to achieve. (Same question was asked in this [StackOverflow post](https://stackoverflow.com/questions/76541932/integration-tests-with-bigquerys-jsonstreamwriter-in-java))

I couldn't find anything related to this in the official documentation or in the Javadocs. What we need is to understand how to configure the Java client to point to the container started locally.

I have tried a few different configurations like this:
```java
JsonStreamWriter writer = JsonStreamWriter.newBuilder(
TableName.of(BQ_DATASET, BQ_PROJECT, BQ_TABLE).toString(),
BigQueryWriteClient.create(
BigQueryWriteSettings.newBuilder()
.setTransportChannelProvider(
FixedTransportChannelProvider.create(
GrpcTransportChannel.create(
NettyChannelBuilder.forTarget("localhost:9060")
.usePlaintext()
.build()
)
)
)
.setCredentialsProvider(NoCredentialsProvider.create())
.build()
)
).build();
```

Would it be possible to update the docs or the GitHub repo and provide an example of how can this be achieved?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.