Search in sources :

Example 1 with JobConfiguration

use of com.google.cloud.bigquery.JobConfiguration in project google-cloud-java by GoogleCloudPlatform.

the class ITJobSnippets method testExists.

@Test
public void testExists() 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);
    boolean result = jobSnippets.exists();
    assertTrue(result);
}
Also used : JobInfo(com.google.cloud.bigquery.JobInfo) Job(com.google.cloud.bigquery.Job) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration) JobConfiguration(com.google.cloud.bigquery.JobConfiguration) Test(org.junit.Test)

Example 2 with JobConfiguration

use of com.google.cloud.bigquery.JobConfiguration in project google-cloud-java by GoogleCloudPlatform.

the class ITJobSnippets method testWaitFor.

@Test
public void testWaitFor() 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);
    boolean result = jobSnippets.waitFor();
    assertTrue(result);
}
Also used : JobInfo(com.google.cloud.bigquery.JobInfo) Job(com.google.cloud.bigquery.Job) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration) JobConfiguration(com.google.cloud.bigquery.JobConfiguration) Test(org.junit.Test)

Example 3 with JobConfiguration

use of com.google.cloud.bigquery.JobConfiguration in project google-cloud-java by GoogleCloudPlatform.

the class ITJobSnippets method testCancel.

@Test
public void testCancel() {
    JobConfiguration jobConfig = QueryJobConfiguration.newBuilder(QUERY).setUseLegacySql(false).build();
    JobInfo jobInfo = JobInfo.newBuilder(jobConfig).build();
    Job job = bigquery.create(jobInfo);
    JobSnippets jobSnippets = new JobSnippets(job);
    boolean result = jobSnippets.cancel();
    assertTrue(result);
}
Also used : JobInfo(com.google.cloud.bigquery.JobInfo) Job(com.google.cloud.bigquery.Job) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration) JobConfiguration(com.google.cloud.bigquery.JobConfiguration) Test(org.junit.Test)

Example 4 with JobConfiguration

use of com.google.cloud.bigquery.JobConfiguration in project google-cloud-java by GoogleCloudPlatform.

the class ITJobSnippets method testIsDone.

@Test
public void testIsDone() 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);
    jobSnippets.isDone();
    assertTrue(job.isDone());
}
Also used : JobInfo(com.google.cloud.bigquery.JobInfo) Job(com.google.cloud.bigquery.Job) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration) JobConfiguration(com.google.cloud.bigquery.JobConfiguration) Test(org.junit.Test)

Example 5 with JobConfiguration

use of com.google.cloud.bigquery.JobConfiguration in project google-cloud-java by GoogleCloudPlatform.

the class BigQuerySnippets method createJob.

/**
   * Example of creating a query job.
   */
// [TARGET create(JobInfo, JobOption...)]
// [VARIABLE "SELECT field FROM my_dataset_name.my_table_name"]
public Job createJob(String query) {
    // [START createJob]
    Job job = null;
    JobConfiguration jobConfiguration = QueryJobConfiguration.of(query);
    JobInfo jobInfo = JobInfo.of(jobConfiguration);
    try {
        job = bigquery.create(jobInfo);
    } catch (BigQueryException e) {
    // the job was not created
    }
    // [END createJob]
    return job;
}
Also used : JobInfo(com.google.cloud.bigquery.JobInfo) BigQueryException(com.google.cloud.bigquery.BigQueryException) Job(com.google.cloud.bigquery.Job) JobConfiguration(com.google.cloud.bigquery.JobConfiguration) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration)

Aggregations

Job (com.google.cloud.bigquery.Job)8 JobConfiguration (com.google.cloud.bigquery.JobConfiguration)8 JobInfo (com.google.cloud.bigquery.JobInfo)8 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)8 Test (org.junit.Test)7 JobStatus (com.google.cloud.bigquery.JobStatus)2 BigQueryException (com.google.cloud.bigquery.BigQueryException)1