com.google.api.services.bigquery.model.JobStatus toPb() { com.google.api.services.bigquery.model.JobStatus statusPb = new com.google.api.services.bigquery.model.JobStatus(); if (state != null) { statusPb.setState(state.toString()); } if (error != null) { statusPb.setErrorResult(error.toPb()); } if (executionErrors != null) { statusPb.setErrors(Lists.transform(executionErrors, BigQueryError.TO_PB_FUNCTION)); } return statusPb; }
/** Example of running a batch query. */ public void runBatchQuery() throws TimeoutException, InterruptedException { // [START bigquery_query_batch] // BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query) // Run at batch priority, which won't count toward concurrent rate // limit. .setPriority(QueryJobConfiguration.Priority.BATCH) .build(); // Location must match that of the dataset(s) referenced in the query. JobId jobId = JobId.newBuilder().setRandomJob().setLocation("US").build(); String jobIdString = jobId.getJob(); // API request - starts the query. bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build()); // Check on the progress by getting the job's updated state. Once the state // is `DONE`, the results are ready. Job queryJob = bigquery.getJob(JobId.newBuilder().setJob(jobIdString).setLocation("US").build()); System.out.printf( "Job %s in location %s currently in state: %s%n", queryJob.getJobId().getJob(), queryJob.getJobId().getLocation(), queryJob.getStatus().getState().toString()); // [END bigquery_query_batch] }
com.google.api.services.bigquery.model.JobStatus toPb() { com.google.api.services.bigquery.model.JobStatus statusPb = new com.google.api.services.bigquery.model.JobStatus(); if (state != null) { statusPb.setState(state.toString()); } if (error != null) { statusPb.setErrorResult(error.toPb()); } if (executionErrors != null) { statusPb.setErrors(Lists.transform(executionErrors, BigQueryError.TO_PB_FUNCTION)); } return statusPb; }
com.google.api.services.bigquery.model.JobStatus toPb() { com.google.api.services.bigquery.model.JobStatus statusPb = new com.google.api.services.bigquery.model.JobStatus(); if (state != null) { statusPb.setState(state.toString()); } if (error != null) { statusPb.setErrorResult(error.toPb()); } if (executionErrors != null) { statusPb.setErrors(Lists.transform(executionErrors, BigQueryError.TO_PB_FUNCTION)); } return statusPb; }