Skip to content

Commit 1c8f392

Browse files
authored
Add docs for BigQuery Client creation (#7528)
1 parent d99b472 commit 1c8f392

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/modules/gcloud.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Start BigQuery Emulator during a test:
2626
[Starting a BigQuery Emulator container](../../modules/gcloud/src/test/java/org/testcontainers/containers/BigQueryEmulatorContainerTest.java) inside_block:emulatorContainer
2727
<!--/codeinclude-->
2828

29+
<!--codeinclude-->
30+
[Creating BigQuery Client](../../modules/gcloud/src/test/java/org/testcontainers/containers/BigQueryEmulatorContainerTest.java) inside_block:bigQueryClient
31+
<!--/codeinclude-->
32+
2933
### Bigtable
3034

3135
Start Bigtable Emulator during a test:

modules/gcloud/src/test/java/org/testcontainers/containers/BigQueryEmulatorContainerTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.testcontainers.containers;
22

3+
import com.google.cloud.NoCredentials;
34
import com.google.cloud.bigquery.BigQuery;
45
import com.google.cloud.bigquery.BigQueryOptions;
56
import com.google.cloud.bigquery.QueryJobConfiguration;
@@ -23,14 +24,17 @@ public void test() throws Exception {
2324
) {
2425
container.start();
2526

27+
// bigQueryClient {
2628
String url = container.getEmulatorHttpEndpoint();
2729
BigQueryOptions options = BigQueryOptions
2830
.newBuilder()
2931
.setProjectId(container.getProjectId())
3032
.setHost(url)
3133
.setLocation(url)
34+
.setCredentials(NoCredentials.getInstance())
3235
.build();
3336
BigQuery bigQuery = options.getService();
37+
// }
3438

3539
String fn =
3640
"CREATE FUNCTION testr(arr ARRAY<STRUCT<name STRING, val INT64>>) AS ((SELECT SUM(IF(elem.name = \"foo\",elem.val,null)) FROM UNNEST(arr) AS elem))";

0 commit comments

Comments
 (0)