diff --git a/pom.xml b/pom.xml
index d702e44..0fb0f26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
io.cdap.delta
bigquery-delta-plugins
- 0.9.0-SNAPSHOT
+ 0.9.1-SNAPSHOT
BigQuery Delta plugins
jar
BigQuery Delta plugins
diff --git a/src/main/java/io/cdap/delta/bigquery/BigQueryTarget.java b/src/main/java/io/cdap/delta/bigquery/BigQueryTarget.java
index 7723884..5be74e2 100644
--- a/src/main/java/io/cdap/delta/bigquery/BigQueryTarget.java
+++ b/src/main/java/io/cdap/delta/bigquery/BigQueryTarget.java
@@ -17,7 +17,9 @@
package io.cdap.delta.bigquery;
import com.google.auth.Credentials;
+import com.google.auth.oauth2.ExternalAccountCredentials;
import com.google.auth.oauth2.GoogleCredentials;
+import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.ServiceOptions;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryException;
@@ -30,6 +32,7 @@
import com.google.cloud.storage.StorageOptions;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
+import com.google.common.base.Strings;
import io.cdap.cdap.api.annotation.Description;
import io.cdap.cdap.api.annotation.Macro;
import io.cdap.cdap.api.annotation.Name;
@@ -54,8 +57,10 @@
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
@@ -80,6 +85,9 @@ public class BigQueryTarget implements DeltaTarget {
private static final int RETRY_COUNT = 25;
private final int retryCount;
private final Conf conf;
+ public static final List BIGQUERY_SCOPES = Arrays.asList("https://www.googleapis.com/auth/drive",
+ "https://www.googleapis.com/auth/bigquery");
+
@SuppressWarnings("unused")
public BigQueryTarget(Conf conf) {
@@ -98,19 +106,23 @@ public void configure(Configurer configurer) {
@Override
public void initialize(DeltaTargetContext context) throws Exception {
+
Credentials credentials = conf.getCredentials();
- String project = conf.getProject();
+
+ if (conf.getProject() == null) {
+ return;
+ }
+ String project = conf.getDatasetProject();
+ if (project == null) {
+ return;
+ }
String cmekKey = context.getRuntimeArguments().get(GCP_CMEK_KEY_NAME) != null ?
context.getRuntimeArguments().get(GCP_CMEK_KEY_NAME) : conf.getEncryptionKeyName();
EncryptionConfiguration encryptionConfig = cmekKey == null ? null :
EncryptionConfiguration.newBuilder().setKmsKeyName(cmekKey).build();
- BigQuery bigQuery = BigQueryOptions.newBuilder()
- .setCredentials(credentials)
- .setProjectId(project)
- .build()
- .getService();
+ BigQuery bigQuery = getBigQuery(project, credentials);
RetryPolicy