Skip to content

Commit 84d6632

Browse files
author
Praful Makani
authored
feat: use bigquery exception (#749)
1 parent 8003928 commit 84d6632

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,7 @@ public Job reload(JobOption... options) {
403403
checkNotDryRun("reload");
404404
Job job = bigquery.getJob(getJobId(), options);
405405
if (job != null && job.getStatus().getError() != null) {
406-
// TODO(pmakani): change to BigQueryException when fast query path change is merged
407-
throw new JobException(
408-
getJobId(),
406+
throw new BigQueryException(
409407
job.getStatus().getExecutionErrors() == null
410408
? ImmutableList.of(job.getStatus().getError())
411409
: ImmutableList.copyOf(job.getStatus().getExecutionErrors()));

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ public void testReloadJobException() {
447447
expectedJob =
448448
expectedJob.toBuilder().setStatus(new JobStatus(State.DONE, bigQueryError, null)).build();
449449
ImmutableList<BigQueryError> bigQueryErrorList = ImmutableList.of(bigQueryError);
450-
JobException jobException = new JobException(expectedJob.getJobId(), bigQueryErrorList);
451-
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(expectedJob).thenThrow(jobException);
450+
BigQueryException bigQueryException = new BigQueryException(bigQueryErrorList);
451+
when(bigquery.getJob(JOB_INFO.getJobId())).thenReturn(expectedJob).thenThrow(bigQueryException);
452452
try {
453453
job.reload();
454454
fail("JobException expected");
455-
} catch (JobException e) {
455+
} catch (BigQueryException e) {
456456
assertNotNull(e.getErrors());
457457
}
458458
}

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import com.google.cloud.bigquery.InsertAllRequest;
6666
import com.google.cloud.bigquery.InsertAllResponse;
6767
import com.google.cloud.bigquery.Job;
68-
import com.google.cloud.bigquery.JobException;
6968
import com.google.cloud.bigquery.JobId;
7069
import com.google.cloud.bigquery.JobInfo;
7170
import com.google.cloud.bigquery.JobStatistics;
@@ -1493,12 +1492,11 @@ public void testMultipleStatementsQueryException() throws InterruptedException {
14931492
try {
14941493
bigquery.create(JobInfo.of(QueryJobConfiguration.of(invalidQuery))).waitFor();
14951494
fail("JobException was expected");
1496-
} catch (JobException e) {
1497-
for (BigQueryError error : e.getErrors()) {
1498-
assertNotNull(error);
1499-
assertEquals("invalidQuery", error.getReason());
1500-
assertNotNull(error.getMessage());
1501-
}
1495+
} catch (BigQueryException e) {
1496+
BigQueryError error = e.getError();
1497+
assertNotNull(error);
1498+
assertEquals("invalidQuery", error.getReason());
1499+
assertNotNull(error.getMessage());
15021500
}
15031501
}
15041502

0 commit comments

Comments
 (0)