Java Code Examples for com.google.cloud.bigquery.JobInfo#of()
The following examples show how to use
com.google.cloud.bigquery.JobInfo#of() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadSessionCreator.java From presto with Apache License 2.0 | 6 votes |
TableInfo createTableFromQuery() { TableId destinationTable = bigQueryClient.createDestinationTable(table); log.debug("destinationTable is %s", destinationTable); JobInfo jobInfo = JobInfo.of( QueryJobConfiguration .newBuilder(query) .setDestinationTable(destinationTable) .build()); log.debug("running query %s", jobInfo); Job job = waitForJob(bigQueryClient.create(jobInfo)); log.debug("job has finished. %s", job); if (job.getStatus().getError() != null) { throw convertToBigQueryException(job.getStatus().getError()); } // add expiration time to the table TableInfo createdTable = bigQueryClient.getTable(destinationTable); long expirationTime = createdTable.getCreationTime() + TimeUnit.HOURS.toMillis(config.viewExpirationTimeInHours); Table updatedTable = bigQueryClient.update(createdTable.toBuilder() .setExpirationTime(expirationTime) .build()); return updatedTable; }
Example 2
Source File: BigQuerySnippets.java From google-cloud-java with Apache License 2.0 | 6 votes |
/** Example of creating a query job. */ // [TARGET create(JobInfo, JobOption...)] // [VARIABLE "SELECT field FROM my_dataset_name.my_table_name"] public Job createJob(String query) { // [START ] Job job = null; JobConfiguration jobConfiguration = QueryJobConfiguration.of(query); JobInfo jobInfo = JobInfo.of(jobConfiguration); try { job = bigquery.create(jobInfo); } catch (BigQueryException e) { // the job was not created } // [END ] return job; }
Example 3
Source File: BigQueryExample.java From google-cloud-java with Apache License 2.0 | 5 votes |
@Override JobInfo parse(String... args) throws Exception { if (args.length >= 4) { String dataset = args[0]; String table = args[1]; String format = args[2]; TableId tableId = TableId.of(dataset, table); LoadJobConfiguration configuration = LoadJobConfiguration.of( tableId, Arrays.asList(args).subList(3, args.length), FormatOptions.of(format)); return JobInfo.of(configuration); } throw new IllegalArgumentException("Missing required arguments."); }
Example 4
Source File: BigQueryExample.java From google-cloud-java with Apache License 2.0 | 5 votes |
@Override JobInfo parse(String... args) throws Exception { if (args.length >= 4) { String dataset = args[0]; String table = args[1]; String format = args[2]; TableId tableId = TableId.of(dataset, table); ExtractJobConfiguration configuration = ExtractJobConfiguration.of( tableId, Arrays.asList(args).subList(3, args.length), format); return JobInfo.of(configuration); } throw new IllegalArgumentException("Missing required arguments."); }
Example 5
Source File: BigQueryExample.java From google-cloud-java with Apache License 2.0 | 5 votes |
@Override JobInfo parse(String... args) throws Exception { String message; if (args.length == 4) { TableId sourceTableId = TableId.of(args[0], args[1]); TableId destinationTableId = TableId.of(args[2], args[3]); return JobInfo.of(CopyJobConfiguration.of(destinationTableId, sourceTableId)); } else if (args.length < 3) { message = "Missing required source or destination table."; } else { message = "Too many arguments."; } throw new IllegalArgumentException(message); }