Skip to content

Commit 2c10178

Browse files
Adding BigQuery integration test for query dry runs
1 parent fb49529 commit 2c10178

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.cloud.bigquery.it;
1818

19+
import static com.google.cloud.bigquery.JobStatus.State.DONE;
1920
import static org.junit.Assert.assertArrayEquals;
2021
import static org.junit.Assert.assertEquals;
2122
import static org.junit.Assert.assertFalse;
@@ -1067,6 +1068,26 @@ public void testQueryJob() throws InterruptedException, TimeoutException {
10671068
assertNotNull(statistics.getQueryPlan());
10681069
}
10691070

1071+
@Test
1072+
public void testQueryJobWithDryRun() throws InterruptedException, TimeoutException {
1073+
String tableName = "test_query_job_table";
1074+
String query = new StringBuilder()
1075+
.append("SELECT TimestampField, StringField, BooleanField FROM ")
1076+
.append(TABLE_ID.getTable())
1077+
.toString();
1078+
TableId destinationTable = TableId.of(DATASET, tableName);
1079+
QueryJobConfiguration configuration = QueryJobConfiguration.newBuilder(query)
1080+
.setDefaultDataset(DatasetId.of(DATASET))
1081+
.setDestinationTable(destinationTable)
1082+
.setDryRun(true)
1083+
.build();
1084+
Job remoteJob = bigquery.create(JobInfo.of(configuration));
1085+
System.out.println("job (dryrun): " + remoteJob);
1086+
assertNull(remoteJob.getJobId().getJob());
1087+
assertEquals(DONE, remoteJob.getStatus().getState());
1088+
assertNotNull(remoteJob.getConfiguration());
1089+
}
1090+
10701091
@Test
10711092
public void testExtractJob() throws InterruptedException, TimeoutException {
10721093
String tableName = "test_export_job_table";

0 commit comments

Comments
 (0)