Skip to content

Commit

Permalink
Add docs for BigQuery Client creation (#7528)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciorby committed Sep 15, 2023
1 parent d99b472 commit 1c8f392
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/modules/gcloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Start BigQuery Emulator during a test:
[Starting a BigQuery Emulator container](../../modules/gcloud/src/test/java/org/testcontainers/containers/BigQueryEmulatorContainerTest.java) inside_block:emulatorContainer
<!--/codeinclude-->

<!--codeinclude-->
[Creating BigQuery Client](../../modules/gcloud/src/test/java/org/testcontainers/containers/BigQueryEmulatorContainerTest.java) inside_block:bigQueryClient
<!--/codeinclude-->

### Bigtable

Start Bigtable Emulator during a test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.testcontainers.containers;

import com.google.cloud.NoCredentials;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.QueryJobConfiguration;
Expand All @@ -23,14 +24,17 @@ public void test() throws Exception {
) {
container.start();

// bigQueryClient {
String url = container.getEmulatorHttpEndpoint();
BigQueryOptions options = BigQueryOptions
.newBuilder()
.setProjectId(container.getProjectId())
.setHost(url)
.setLocation(url)
.setCredentials(NoCredentials.getInstance())
.build();
BigQuery bigQuery = options.getService();
// }

String fn =
"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))";
Expand Down

0 comments on commit 1c8f392

Please sign in to comment.