Skip to content
Permalink
Browse files
feat: use bigquery exception (#749)
  • Loading branch information
Praful Makani committed Sep 23, 2020
1 parent 8003928 commit 84d6632dbbdb9ccaf4afba545ec94a1156a989a2
@@ -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()));
@@ -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());
}
}
@@ -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;
@@ -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());
}
}

0 comments on commit 84d6632

Please sign in to comment.