use of com.google.cloud.bigquery.BigQuery.JobOption in project google-cloud-java by GoogleCloudPlatform.
the class TableSnippets method copyTableId.
/**
* 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 copyTableId]
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(WaitForOption.checkEvery(1, TimeUnit.SECONDS), WaitForOption.timeout(3, TimeUnit.MINUTES));
if (completedJob != null && completedJob.getStatus().getError() == null) {
// Job completed successfully.
} else {
// Handle error case.
}
} catch (InterruptedException | TimeoutException e) {
// Handle interrupted wait
}
// [END copyTableId]
return job;
}
Aggregations