Skip to content

Commit

Permalink
chore: update method and credentials (#79)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
stephaniewang526 committed Jan 7, 2020
1 parent 53e66ce commit a331eaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 2 additions & 6 deletions .kokoro/run_samples_tests.sh
Expand Up @@ -28,12 +28,8 @@ echo "********** MAVEN INFO ***********"
mvn -v

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

# Activate service account
gcloud auth activate-service-account \
Expand Down
Expand Up @@ -17,12 +17,14 @@
package com.example.bigquery;

// [START bigquery_extract_table]
import com.google.cloud.RetryOption;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryException;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.Job;
import com.google.cloud.bigquery.Table;
import com.google.cloud.bigquery.TableId;
import org.threeten.bp.Duration;

public class ExtractTableToJson {

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

// Blocks until this job completes its execution, either failing or succeeding.
Job completedJob = job.waitFor();
Job completedJob =
job.waitFor(
RetryOption.initialRetryDelay(Duration.ofSeconds(1)),
RetryOption.totalTimeout(Duration.ofMinutes(3)));
if (completedJob == null) {
System.out.println("Job not executed since it no longer exists.");
return;
Expand Down

0 comments on commit a331eaa

Please sign in to comment.