code: public void runQuery() throws InterruptedException {
      // [START bigquery_query]
      // BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
      String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
      QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();
  
      // Print the results.
      for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {
        for (FieldValue val : row) {
          System.out.printf("%s,", val.toString());
        }
        System.out.printf("\n");
      }
      // [END bigquery_query]
    }
docs: [TARGET query(QueryJobConfiguration, JobOption...)]