code: 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]
    }
docs: Example of running a batch query.