Java Code Examples for com.google.cloud.bigquery.JobStatus#State

The following examples show how to use com.google.cloud.bigquery.JobStatus#State . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
/** Example of reloading all fields until job status is DONE. */
// [TARGET reload(JobOption...)]
public JobStatus.State reload() throws InterruptedException {
  // [START ]
  while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
    Thread.sleep(1000L);
    job = job.reload();
  }
  // [END ]
  return job.getStatus().getState();
}
 
Example 2
Source File: JobSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
/** Example of reloading status field until job status is DONE. */
// [TARGET reload(JobOption...)]
public JobStatus.State reloadStatus() throws InterruptedException {
  // [START ]
  while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
    Thread.sleep(1000L);
    job = job.reload(BigQuery.JobOption.fields(BigQuery.JobField.STATUS));
  }
  // [END ]
  return job.getStatus().getState();
}
 
Example 3
Source File: ITJobSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testReload() throws Exception {
  JobConfiguration jobConfig =
      QueryJobConfiguration.newBuilder(QUERY).setUseLegacySql(false).build();
  JobInfo jobInfo = JobInfo.newBuilder(jobConfig).build();
  Job job = bigquery.create(jobInfo);
  JobSnippets jobSnippets = new JobSnippets(job);
  JobStatus.State result = jobSnippets.reload();
  assertEquals(JobStatus.State.DONE, result);
}
 
Example 4
Source File: ITJobSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testReloadStatus() throws Exception {
  JobConfiguration jobConfig =
      QueryJobConfiguration.newBuilder(QUERY).setUseLegacySql(false).build();
  JobInfo jobInfo = JobInfo.newBuilder(jobConfig).build();
  Job job = bigquery.create(jobInfo);
  JobSnippets jobSnippets = new JobSnippets(job);
  JobStatus.State result = jobSnippets.reloadStatus();
  assertEquals(JobStatus.State.DONE, result);
}