Skip to content

Commit

Permalink
Adding BigQuery integration test for query dry runs (#2328)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjonesgoogle authored Aug 10, 2017
1 parent fb49529 commit 58e76bb
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.cloud.bigquery.it;

import static com.google.cloud.bigquery.JobStatus.State.DONE;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -1067,6 +1068,26 @@ public void testQueryJob() throws InterruptedException, TimeoutException {
assertNotNull(statistics.getQueryPlan());
}

@Test
public void testQueryJobWithDryRun() throws InterruptedException, TimeoutException {
String tableName = "test_query_job_table";
String query = new StringBuilder()
.append("SELECT TimestampField, StringField, BooleanField FROM ")
.append(TABLE_ID.getTable())
.toString();
TableId destinationTable = TableId.of(DATASET, tableName);
QueryJobConfiguration configuration = QueryJobConfiguration.newBuilder(query)
.setDefaultDataset(DatasetId.of(DATASET))
.setDestinationTable(destinationTable)
.setDryRun(true)
.build();
Job remoteJob = bigquery.create(JobInfo.of(configuration));
System.out.println("job (dryrun): " + remoteJob);
assertNull(remoteJob.getJobId().getJob());
assertEquals(DONE, remoteJob.getStatus().getState());
assertNotNull(remoteJob.getConfiguration());
}

@Test
public void testExtractJob() throws InterruptedException, TimeoutException {
String tableName = "test_export_job_table";
Expand Down

0 comments on commit 58e76bb

Please sign in to comment.