return copy(TableId.of(destinationDataset, destinationTable), options);
@Test public void testCopyFromString() throws Exception { initializeExpectedTable(2); expect(bigquery.getOptions()).andReturn(mockOptions); Job expectedJob = new Job(serviceMockReturnsOptions, new JobInfo.BuilderImpl(COPY_JOB_INFO)); expect(bigquery.create(COPY_JOB_INFO)).andReturn(expectedJob); replay(bigquery); initializeTable(); Job job = table.copy(TABLE_ID2.getDataset(), TABLE_ID2.getTable()); assertSame(expectedJob, job); }
@Test public void testCopyFromId() throws Exception { initializeExpectedTable(2); expect(bigquery.getOptions()).andReturn(mockOptions); Job expectedJob = new Job(serviceMockReturnsOptions, new JobInfo.BuilderImpl(COPY_JOB_INFO)); expect(bigquery.create(COPY_JOB_INFO)).andReturn(expectedJob); replay(bigquery); initializeTable(); Job job = table.copy(TABLE_ID2.getDataset(), TABLE_ID2.getTable()); assertSame(expectedJob, job); }
/** Example of copying the table to a destination table. */ // [TARGET copy(String, String, JobOption...)] // [VARIABLE "my_dataset"] // [VARIABLE "my_destination_table"] public Job copy(String datasetName, String tableName) { // [START ] Job job = table.copy(datasetName, tableName); // Wait for the job to complete. try { Job completedJob = job.waitFor( RetryOption.initialRetryDelay(Duration.ofSeconds(1)), RetryOption.totalTimeout(Duration.ofMinutes(3))); if (completedJob != null && completedJob.getStatus().getError() == null) { // Job completed successfully } else { // Handle error case } } catch (InterruptedException e) { // Handle interrupted wait } // [END ] return job; }
/** Example copying the table to a destination table. */ // [TARGET copy(TableId, JobOption...)] // [VARIABLE "my_dataset"] // [VARIABLE "my_destination_table"] public Job copyTableId(String dataset, String tableName) throws BigQueryException { // [START bigquery_copy_table] TableId destinationId = TableId.of(dataset, tableName); JobOption options = JobOption.fields(JobField.STATUS, JobField.USER_EMAIL); Job job = table.copy(destinationId, options); // Wait for the job to complete. try { Job completedJob = job.waitFor( RetryOption.initialRetryDelay(Duration.ofSeconds(1)), RetryOption.totalTimeout(Duration.ofMinutes(3))); if (completedJob != null && completedJob.getStatus().getError() == null) { // Job completed successfully. } else { // Handle error case. } } catch (InterruptedException e) { // Handle interrupted wait } // [END bigquery_copy_table] return job; }
/** * Starts a BigQuery Job to copy the current table to the provided destination table. Returns the * started {@link Job} object. * * @param destinationDataset the user-defined id of the destination dataset * @param destinationTable the user-defined id of the destination table * @param options job options * @throws BigQueryException upon failure */ public Job copy(String destinationDataset, String destinationTable, BigQuery.JobOption... options) throws BigQueryException { return copy(TableId.of(destinationDataset, destinationTable), options); }
return copy(TableId.of(destinationDataset, destinationTable), options);