class BigQueryConfiguration {

  public static void configureBigQueryInput(
      Configuration config,
      String projectId,
      String datasetId,
      String tableId)
      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.");

    // Project is optional, if not set use default project.
    if (!Strings.isNullOrEmpty(projectId)) {
      logger.atInfo().log("Using specified project-id '%s' for input", projectId);
      config.set(INPUT_PROJECT_ID.getKey(), 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(PROJECT_ID.get(config, config::get))) {
        logger.atWarning().log(
            "No job-level projectId specified in '%s', using '%s' for it.",
            PROJECT_ID.getKey(), projectId);
        config.set(PROJECT_ID.getKey(), projectId);
      }
    } else {
      String defaultProjectId = getMandatoryConfig(config, PROJECT_ID);
      logger.atInfo().log(
          "Using default project-id '%s' since none specified for input.", defaultProjectId);
      config.set(INPUT_PROJECT_ID.getKey(), defaultProjectId);
    }
    config.set(INPUT_DATASET_ID.getKey(), datasetId);
    config.set(INPUT_TABLE_ID.getKey(), tableId);
  }

}