Skip to content

Commit

Permalink
feat: use bigquery exception (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
Praful Makani committed Sep 23, 2020
1 parent 8003928 commit 84d6632
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Expand Up @@ -403,9 +403,7 @@ public Job reload(JobOption... options) {
checkNotDryRun("reload");
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(),
throw new BigQueryException(
job.getStatus().getExecutionErrors() == null
? ImmutableList.of(job.getStatus().getError())
: ImmutableList.copyOf(job.getStatus().getExecutionErrors()));
Expand Down
Expand Up @@ -447,12 +447,12 @@ public void testReloadJobException() {
expectedJob =
expectedJob.toBuilder().setStatus(new JobStatus(State.DONE, bigQueryError, null)).build();
ImmutableList<BigQueryError> bigQueryErrorList = ImmutableList.of(bigQueryError);
JobException jobException = new JobException(expectedJob.getJobId(), bigQueryErrorList);
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(expectedJob).thenThrow(jobException);
BigQueryException bigQueryException = new BigQueryException(bigQueryErrorList);
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(expectedJob).thenThrow(bigQueryException);
try {
job.reload();
fail("JobException expected");
} catch (JobException e) {
} catch (BigQueryException e) {
assertNotNull(e.getErrors());
}
}
Expand Down
Expand Up @@ -65,7 +65,6 @@
import com.google.cloud.bigquery.InsertAllRequest;
import com.google.cloud.bigquery.InsertAllResponse;
import com.google.cloud.bigquery.Job;
import com.google.cloud.bigquery.JobException;
import com.google.cloud.bigquery.JobId;
import com.google.cloud.bigquery.JobInfo;
import com.google.cloud.bigquery.JobStatistics;
Expand Down Expand Up @@ -1493,12 +1492,11 @@ public void testMultipleStatementsQueryException() throws InterruptedException {
try {
bigquery.create(JobInfo.of(QueryJobConfiguration.of(invalidQuery))).waitFor();
fail("JobException was expected");
} catch (JobException e) {
for (BigQueryError error : e.getErrors()) {
assertNotNull(error);
assertEquals("invalidQuery", error.getReason());
assertNotNull(error.getMessage());
}
} catch (BigQueryException e) {
BigQueryError error = e.getError();
assertNotNull(error);
assertEquals("invalidQuery", error.getReason());
assertNotNull(error.getMessage());
}
}

Expand Down

0 comments on commit 84d6632

Please sign in to comment.