Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support location in bq operator #1767

Merged
merged 6 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ abstract class BaseBqJobOperator
protected TaskResult run(BqClient bq, String projectId)
{
BqJobRunner jobRunner = new BqJobRunner(request, bq, projectId);
Job completed = jobRunner.runJob(jobConfiguration(projectId));
String location = params.getOptional("location", String.class).orNull();
tkawachi marked this conversation as resolved.
Show resolved Hide resolved
Job completed = jobRunner.runJob(jobConfiguration(projectId), location);
return result(completed);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ void submitJob(String projectId, Job job)
.execute();
}

Job jobStatus(String projectId, String jobId)
Job jobStatus(String projectId, String jobId, String location)
throws IOException
{
return client.jobs()
.get(projectId, jobId)
// newer version of google-api-services-bigquery-v2 has setLocation()
.set("location", location)
tkawachi marked this conversation as resolved.
Show resolved Hide resolved
.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BqJobRunner
this.projectId = Objects.requireNonNull(projectId, "projectId");
}

Job runJob(JobConfiguration config)
Job runJob(JobConfiguration config, String location)
{
// Generate job id
Optional<String> jobId = state.params().getOptional(JOB_ID, String.class);
Expand Down Expand Up @@ -97,7 +97,7 @@ Job runJob(JobConfiguration config)
.withErrorMessage("BigQuery job status check failed: %s", canonicalJobId)
.run(s -> {
logger.info("Checking BigQuery job status: {}", canonicalJobId);
return bq.jobStatus(projectId, jobId.get());
return bq.jobStatus(projectId, jobId.get(), location);
});

// Done yet?
Expand Down