public static void configureBigQueryOutput(
      Configuration config,
      String projectId,
      String datasetId,
      String tableId,
      String tableSchema)
      throws IOException {
    // Check preconditions.
    Preconditions.checkArgument(
        !Strings.isNullOrEmpty(datasetId), "datasetId must not be null or empty.");
    Preconditions.checkArgument(
        !Strings.isNullOrEmpty(tableId), "tableId must not be null or empty.");
    Preconditions.checkArgument(
        !Strings.isNullOrEmpty(tableSchema), "tableSchema must not be null or empty.");

    // Project is optional, if not set use default project.
    if (!Strings.isNullOrEmpty(projectId)) {
      logger.atInfo().log("Using specified project-id '%s' for output", projectId);
      config.set(OUTPUT_PROJECT_ID_KEY, projectId);

      // For user-friendliness, we'll helpfully backfill the input-specific projectId into the
      // "global" projectId for now.
      // TODO(user): Maybe don't try to be user-friendly here.
      if (Strings.isNullOrEmpty(config.get(PROJECT_ID_KEY))) {
        logger.atWarning().log(
            "No job-level projectId specified in '%s', using '%s' for it.",
            PROJECT_ID_KEY, projectId);
        config.set(PROJECT_ID_KEY, projectId);
      }
    } else {
      String defaultProjectId = ConfigurationUtil.getMandatoryConfig(config, PROJECT_ID_KEY);
      logger.atInfo().log(
          "Using default project-id '%s' since none specified for output.", defaultProjectId);
      config.set(OUTPUT_PROJECT_ID_KEY, defaultProjectId);
    }
    config.set(OUTPUT_DATASET_ID_KEY, datasetId);
    config.set(OUTPUT_TABLE_ID_KEY, tableId);
    config.set(OUTPUT_TABLE_SCHEMA_KEY, tableSchema);
  }
public static void configureBigQueryOutput ( Configuration config , String projectId , String datasetId , String tableId , String tableSchema ) throws IOException { Preconditions . checkArgument ( ! Strings . isNullOrEmpty ( datasetId ) , "datasetId must not be null or empty." ) ; Preconditions . checkArgument ( ! Strings . isNullOrEmpty ( tableId ) , "tableId must not be null or empty." ) ; Preconditions . checkArgument ( ! Strings . isNullOrEmpty ( tableSchema ) , "tableSchema must not be null or empty." ) ; if ( ! Strings . isNullOrEmpty ( projectId ) ) { logger . atInfo ( ) . log ( "Using specified project-id '%s' for output" , projectId ) ; config . set ( OUTPUT_PROJECT_ID_KEY , projectId ) ; if ( Strings . isNullOrEmpty ( config . get ( PROJECT_ID_KEY ) ) ) { logger . atWarning ( ) . log ( "No job-level projectId specified in '%s', using '%s' for it." , PROJECT_ID_KEY , projectId ) ; config . set ( PROJECT_ID_KEY , projectId ) ; } } else { String defaultProjectId = ConfigurationUtil . getMandatoryConfig ( config , PROJECT_ID_KEY ) ; logger . atInfo ( ) . log ( "Using default project-id '%s' since none specified for output." , defaultProjectId ) ; config . set ( OUTPUT_PROJECT_ID_KEY , defaultProjectId ) ; } config . set ( OUTPUT_DATASET_ID_KEY , datasetId ) ; config . set ( OUTPUT_TABLE_ID_KEY , tableId ) ; config . set ( OUTPUT_TABLE_SCHEMA_KEY , tableSchema ) ; }
Sets the Bigquery access related fields in the JobConf for output connector.

@param config the job configuration.
@param projectId the project containing the table to write the results to.
@param datasetId the dataset to write the results to.
@param tableId the table to write the results to.
@param tableSchema the output table schema used by this output connector.