Skip to content

Commit

Permalink
update reload() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephaniewang526 committed Sep 15, 2020
1 parent 86c29dd commit c91ddd3
Showing 1 changed file with 10 additions and 16 deletions.
Expand Up @@ -245,21 +245,6 @@ public Job waitFor(RetryOption... waitOptions) throws InterruptedException {
waitForJob(RetryOption.mergeToSettings(DEFAULT_QUERY_JOB_WAIT_SETTINGS, waitOptions));
}

// Get the job resource to determine if it has errored.
Job job = this;
if (job.getStatus() == null || !JobStatus.State.DONE.equals(job.getStatus().getState())) {
// TODO: check to see if we must reload here
job = reload();
}
if (job.getStatus() != null && job.getStatus().getError() != null) {
// TODO(pmakani/stephwang): Change to BigQueryException when fast query path change is merged
throw new JobException(
getJobId(),
job.getStatus().getExecutionErrors() == null
? ImmutableList.of(job.getStatus().getError())
: ImmutableList.copyOf(job.getStatus().getExecutionErrors()));
}

return completedJobResponse == null ? null : reload();
}

Expand Down Expand Up @@ -416,7 +401,16 @@ public boolean shouldRetry(Throwable prevThrowable, Job prevResponse) {
*/
public Job reload(JobOption... options) {
checkNotDryRun("reload");
return bigquery.getJob(getJobId(), options);
Job job = bigquery.getJob(getJobId(), options);
if (job != null && job.getStatus().getError() != null) {
// TODO(pmakani): change to BigQueryException when fast query path change is merged
throw new JobException(
getJobId(),
job.getStatus().getExecutionErrors() == null
? ImmutableList.of(job.getStatus().getError())
: ImmutableList.copyOf(job.getStatus().getExecutionErrors()));
}
return job;
}

/**
Expand Down

0 comments on commit c91ddd3

Please sign in to comment.