BigQueryOutputConfiguration { public static String getProjectId(Configuration conf) throws IOException { String projectId = OUTPUT_PROJECT_ID.get(conf, conf::get); if (Strings.isNullOrEmpty(projectId)) { projectId = PROJECT_ID.get(conf, conf::get); } if (Strings.isNullOrEmpty(projectId)) { throw new IOException( "Must supply a value for configuration setting: " + OUTPUT_PROJECT_ID.getKey()); } return projectId; }  @SuppressWarnings("rawtypes") static void configure(
      Configuration conf,
      String qualifiedOutputTableId,
      String outputTableSchemaJson,
      String outputGcsPath,
      BigQueryFileFormat outputFileFormat,
      Class<? extends FileOutputFormat> outputFormatClass); @SuppressWarnings("rawtypes") static void configure(
      Configuration conf,
      String qualifiedOutputTableId,
      BigQueryTableSchema outputTableSchema,
      String outputGcsPath,
      BigQueryFileFormat outputFileFormat,
      Class<? extends FileOutputFormat> outputFormatClass); @SuppressWarnings("rawtypes") static void configureWithAutoSchema(
      Configuration conf,
      String qualifiedOutputTableId,
      String outputGcsPath,
      BigQueryFileFormat outputFileFormat,
      Class<? extends FileOutputFormat> outputFormatClass); static void setKmsKeyName(Configuration conf, String kmsKeyName); static void validateConfiguration(Configuration conf); static boolean getCleanupTemporaryDataFlag(Configuration conf); static String getProjectId(Configuration conf); static String getJobProjectId(Configuration conf); static String getKmsKeyName(Configuration conf); static BigQueryFileFormat getFileFormat(Configuration conf); @SuppressWarnings("rawtypes") static FileOutputFormat getFileOutputFormat(Configuration conf); static Path getGcsOutputPath(Configuration conf); static String getCreateDisposition(Configuration conf); static String getWriteDisposition(Configuration conf); static final List<HadoopConfigurationProperty<?>> REQUIRED_PROPERTIES; }
@Test public void testGetProjectId() throws IOException { conf.set(BigQueryConfiguration.OUTPUT_PROJECT_ID.getKey(), TEST_PROJECT_ID); String result = BigQueryOutputConfiguration.getProjectId(conf); assertThat(result).isEqualTo(TEST_PROJECT_ID); }
@Test public void testGetProjectIdBackup() throws IOException { conf.set(BigQueryConfiguration.PROJECT_ID.getKey(), TEST_PROJECT_ID); String result = BigQueryOutputConfiguration.getProjectId(conf); assertThat(result).isEqualTo(TEST_PROJECT_ID); }
@Test public void testGetProjectIdPrecedence() throws IOException { conf.set(BigQueryConfiguration.OUTPUT_PROJECT_ID.getKey(), TEST_PROJECT_ID); conf.set(BigQueryConfiguration.PROJECT_ID.getKey(), TEST_LOAD_PROJECT_ID); String result = BigQueryOutputConfiguration.getProjectId(conf); assertThat(result).isEqualTo(TEST_PROJECT_ID); }
@Test public void testGetProjectIdMissing() throws IOException { assertThrows(IOException.class, () -> BigQueryOutputConfiguration.getProjectId(conf)); }