Skip to content

Commit 1289664

Browse files
authored
Merge pull request #1169 from data-integrations/PLUGIN-1426_fix_job_region
PLUGIN-1426 : setting region according to destination dataset always
2 parents 2b2549c + 1189704 commit 1289664

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/io/cdap/plugin/gcp/bigquery/sqlengine/BigQueryReadDataset.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private SQLReadResult readInternal(SQLReadRequest readRequest,
198198
destinationDatasetId.getDataset(), destDataset.getLocation());
199199
return SQLReadResult.unsupported(datasetName);
200200
}
201+
String jobLocation = srcDataset.getLocation();
201202

202203
Table sourceTable;
203204
try {
@@ -221,7 +222,7 @@ private SQLReadResult readInternal(SQLReadRequest readRequest,
221222
// TRY SNAPSHOT
222223
JobConfiguration jobConfiguration = getBQSnapshotJobConf(sourceTableId, destinationTableId);
223224
SQLReadResult snapshotResult = executeBigQueryJob(jobConfiguration, sourceTable, sourceTableId,
224-
BigQueryJobType.COPY_SNAPSHOT);
225+
BigQueryJobType.COPY_SNAPSHOT, jobLocation);
225226
if (snapshotResult.isSuccessful()) {
226227
BigQuerySQLEngineUtils.updateTableExpiration(bigQuery, destinationTableId, tableTTL);
227228
return snapshotResult;
@@ -236,18 +237,19 @@ private SQLReadResult readInternal(SQLReadRequest readRequest,
236237
sourceConfig.getPartitionTo(),
237238
tableTTL);
238239

239-
return executeBigQueryJob(queryConfig, sourceTable, sourceTableId, BigQueryJobType.QUERY);
240+
return executeBigQueryJob(queryConfig, sourceTable, sourceTableId, BigQueryJobType.QUERY, jobLocation);
240241
}
241242

242243
private SQLReadResult executeBigQueryJob(JobConfiguration jobConfiguration,
243244
Table sourceTable,
244245
TableId sourceTableId,
245-
BigQueryJobType bigQueryJobType)
246+
BigQueryJobType bigQueryJobType,
247+
String jobLocation)
246248
throws InterruptedException {
247249
// Create a job ID so that we can safely retry.
248250
JobId bqJobId = JobId.newBuilder()
249251
.setJob(jobId)
250-
.setLocation(sqlEngineConfig.getLocation())
252+
.setLocation(jobLocation)
251253
.setProject(sqlEngineConfig.getProject())
252254
.build();
253255

0 commit comments

Comments
 (0)