-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
bigquery: try getting job if create fails #2887
Conversation
If we create a job with randomly generated ID, it's highly unlikely that it will with another job created by someone else. When create fails, it is possible that the job was created successfully anyway. Thus, we can be more failure-tolerant by trying to retrieve the job, if create throws. Fixes #2867.
@@ -874,71 +877,95 @@ public void testListTableDataWithOptions() { | |||
assertArrayEquals(TABLE_DATA.toArray(), Iterables.toArray(page.getValues(), List.class)); | |||
} | |||
|
|||
@Test | |||
public void testCreateQueryJob() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looking great. A few nits / questions.
@@ -590,7 +641,8 @@ public Boolean call() { | |||
@Override | |||
public TableResult query(QueryJobConfiguration configuration, JobOption... options) | |||
throws InterruptedException, JobException { | |||
return query(configuration, JobId.of(), options); | |||
Job.checkNotDryRun(configuration, "query"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
try { | ||
return getJob(jobInfo.getJobId()); | ||
} catch (BigQueryException e) { | ||
System.err.println("rethrow"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigqueryRpcMock.create( | ||
JobInfo.of(LOAD_JOB_CONFIGURATION_WITH_PROJECT).toPb(), EMPTY_RPC_OPTIONS)) | ||
.andReturn(COMPLETE_LOAD_JOB.toPb()); | ||
bigqueryRpcMock.create(EasyMock.capture(jobCapture), EasyMock.eq(EMPTY_RPC_OPTIONS))) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigquery = options.getService(); | ||
Job job = bigquery.create(COPY_JOB); | ||
assertEquals(new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_COPY_JOB)), job); | ||
Job job = bigquery.create(QUERY_JOB, JOB_OPTION_FIELDS); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
String selector = (String) capturedOptions.getValue().get(JOB_OPTION_FIELDS.getRpcOption()); | ||
assertThat(selector.split(",")) | ||
.asList() | ||
.containsExactly("jobReference", "configuration", "user_email"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
new Supplier<JobId>() { | ||
@Override | ||
public JobId get() { | ||
return JobId.of(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@tswast PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once Circle is happy
If we create a job with randomly generated ID, it's highly unlikely
that it will with another job created by someone else.
When create fails, it is possible that the job was created successfully
anyway.
Thus, we can be more failure-tolerant by trying to retrieve the job,
if create throws.
Fixes #2867.