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

feat: use bigquery exception #749

Merged
merged 1 commit into from Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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