Skip to content

Commit ecdacc1

Browse files
committed
fix(bigquery-jdbc): fix manual commit mode failure for non-US regions
1 parent be285d4 commit ecdacc1

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,10 @@ public Job create(JobInfo jobInfo, JobOption... options) {
416416
new Supplier<JobId>() {
417417
@Override
418418
public JobId get() {
419-
return JobId.of();
419+
// Explicitly set the location for a new job when provided in options.
420+
// Otherwise, the job may be created with an incorrect location
421+
// (e.g. in transaction mode outside the US).
422+
return JobId.of().setLocation(getOptions().getLocation());
420423
}
421424
};
422425
return create(jobInfo, idProvider, options);

java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpcTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ public void testCreateJobTelemetry() throws Exception {
795795
"{\"kind\":\"bigquery#job\",\"id\":\""
796796
+ PROJECT_ID
797797
+ ":"
798+
+ LOCATION
799+
+ ":"
798800
+ JOB_ID
799801
+ "\",\"status\":{\"state\":\"DONE\"}}");
800802

@@ -804,7 +806,7 @@ public void testCreateJobTelemetry() throws Exception {
804806

805807
verifyRequest("POST", "/projects/" + PROJECT_ID + "/jobs");
806808
Map<String, String> attributes = new HashMap<>();
807-
attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + JOB_ID);
809+
attributes.put("bq.rpc.response.job.id", PROJECT_ID + ":" + LOCATION + ":" + JOB_ID);
808810
attributes.put("bq.rpc.response.job.status.state", "DONE");
809811
verifySpan(
810812
"com.google.cloud.bigquery.BigQueryRpc.createJob",

0 commit comments

Comments
 (0)