Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit a331eaa

Browse files
chore: update method and credentials (#79)
* feat: new sample - Tables: Copy multiple tables b/147141782 * update test to create new destination table for each test since existing table cannot be overwritten and would throw bigquery error * add env vars for sample test builds * update testing var names * format code * chore: update method and credentials 1. update extract table to json job to allow wait time 2. update testing credentials
1 parent 53e66ce commit a331eaa

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

.kokoro/run_samples_tests.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ echo "********** MAVEN INFO ***********"
2828
mvn -v
2929

3030
# Setup required env variables
31-
export GOOGLE_CLOUD_PROJECT=java-docs-samples-testing
32-
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-acct.json
33-
export BIGQUERY_DATASET_NAME=bigquery_test_dataset
34-
export GCS_BUCKET=java-docs-samples-testing
35-
export BIGQUERY_TABLE1=table1
36-
export BIGQUERY_TABLE2=table2
31+
source ${KOKORO_GFILE_DIR}/bigquery_secrets.txt
32+
echo "********** Successfully Set All Environment Variables **********"
3733

3834
# Activate service account
3935
gcloud auth activate-service-account \

samples/src/main/java/com/example/bigquery/ExtractTableToJson.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
package com.example.bigquery;
1818

1919
// [START bigquery_extract_table]
20+
import com.google.cloud.RetryOption;
2021
import com.google.cloud.bigquery.BigQuery;
2122
import com.google.cloud.bigquery.BigQueryException;
2223
import com.google.cloud.bigquery.BigQueryOptions;
2324
import com.google.cloud.bigquery.Job;
2425
import com.google.cloud.bigquery.Table;
2526
import com.google.cloud.bigquery.TableId;
27+
import org.threeten.bp.Duration;
2628

2729
public class ExtractTableToJson {
2830

@@ -54,7 +56,10 @@ public static void extractTableToJson(
5456
Job job = table.extract("CSV", destinationUri);
5557

5658
// Blocks until this job completes its execution, either failing or succeeding.
57-
Job completedJob = job.waitFor();
59+
Job completedJob =
60+
job.waitFor(
61+
RetryOption.initialRetryDelay(Duration.ofSeconds(1)),
62+
RetryOption.totalTimeout(Duration.ofMinutes(3)));
5863
if (completedJob == null) {
5964
System.out.println("Job not executed since it no longer exists.");
6065
return;

0 commit comments

Comments
 (0)