示例#1
0
 @Test
 public void testCreateAndGetJob() {
   String sourceTableName = "test_create_and_get_job_source_table";
   String destinationTableName = "test_create_and_get_job_destination_table";
   TableId sourceTable = TableId.of(DATASET, sourceTableName);
   StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
   TableInfo tableInfo = TableInfo.of(sourceTable, tableDefinition);
   Table createdTable = bigquery.create(tableInfo);
   assertNotNull(createdTable);
   assertEquals(DATASET, createdTable.tableId().dataset());
   assertEquals(sourceTableName, createdTable.tableId().table());
   TableId destinationTable = TableId.of(DATASET, destinationTableName);
   CopyJobConfiguration copyJobConfiguration =
       CopyJobConfiguration.of(destinationTable, sourceTable);
   Job createdJob = bigquery.create(JobInfo.of(copyJobConfiguration));
   Job remoteJob = bigquery.getJob(createdJob.jobId());
   assertEquals(createdJob.jobId(), remoteJob.jobId());
   CopyJobConfiguration createdConfiguration = createdJob.configuration();
   CopyJobConfiguration remoteConfiguration = remoteJob.configuration();
   assertEquals(createdConfiguration.sourceTables(), remoteConfiguration.sourceTables());
   assertEquals(createdConfiguration.destinationTable(), remoteConfiguration.destinationTable());
   assertEquals(createdConfiguration.createDisposition(), remoteConfiguration.createDisposition());
   assertEquals(createdConfiguration.writeDisposition(), remoteConfiguration.writeDisposition());
   assertNotNull(remoteJob.etag());
   assertNotNull(remoteJob.statistics());
   assertNotNull(remoteJob.status());
   assertEquals(createdJob.selfLink(), remoteJob.selfLink());
   assertEquals(createdJob.userEmail(), remoteJob.userEmail());
   assertTrue(createdTable.delete());
   assertTrue(bigquery.delete(DATASET, destinationTableName));
 }
示例#2
0
 @Test
 public void testListJobsWithSelectedFields() {
   Page<Job> jobs = bigquery.listJobs(JobListOption.fields(JobField.USER_EMAIL));
   for (Job job : jobs.values()) {
     assertNotNull(job.jobId());
     assertNotNull(job.status());
     assertNotNull(job.userEmail());
     assertNull(job.statistics());
     assertNull(job.id());
   }
 }
示例#3
0
 @Test
 public void testListJobs() {
   Page<Job> jobs = bigquery.listJobs();
   for (Job job : jobs.values()) {
     assertNotNull(job.jobId());
     assertNotNull(job.statistics());
     assertNotNull(job.status());
     assertNotNull(job.userEmail());
     assertNotNull(job.id());
   }
 }