code: public void exportBigQueryToGcs(String projectId, TableReference tableRef, List<String> gcsPaths,
        boolean awaitCompletion) throws IOException, InterruptedException {
      logger.atFine().log(
          "exportBigQueryToGcs(bigquery, '%s', '%s', '%s', '%s')",
          projectId, BigQueryStrings.toString(tableRef), gcsPaths, awaitCompletion);
      logger.atInfo().log(
          "Exporting table '%s' to %s paths; path[0] is '%s'; awaitCompletion: %s",
          BigQueryStrings.toString(tableRef),
          gcsPaths.size(),
          gcsPaths.isEmpty() ? "(empty)" : gcsPaths.get(0),
          awaitCompletion);
  
      // Create job and configuration.
      JobConfigurationExtract extractConfig = new JobConfigurationExtract();
  
      // Set source.
      extractConfig.setSourceTable(tableRef);
  
      // Set destination.
      extractConfig.setDestinationUris(gcsPaths);
      extractConfig.set("destinationFormat", "NEWLINE_DELIMITED_JSON");
  
      JobConfiguration config = new JobConfiguration();
      config.setExtract(extractConfig);
  
      // Get the table to determine the location
      Table table = getTable(tableRef);
  
      JobReference jobReference =
          createJobReference(projectId, "direct-bigqueryhelper-export", table.getLocation());
  
      Job job = new Job();
      job.setConfiguration(config);
      job.setJobReference(jobReference);
  
      // Insert and run job.
      insertJobOrFetchDuplicate(projectId, job);
  
      if (awaitCompletion) {
        // Poll until job is complete.
        BigQueryUtils.waitForJobCompletion(service, projectId, jobReference, NOP_PROGRESSABLE);
      }
    }
docs: Exports BigQuery results into GCS, polls for completion before returning.
  
  @param projectId the project on whose behalf to perform the export.
  @param tableRef the table to export.
  @param gcsPaths the GCS paths to export to.
  @param awaitCompletion if true, block and poll until job completes, otherwise return as soon as
  the job has been successfully dispatched.
  
  @throws IOException on IO error.
  @throws InterruptedException on interrupt.