BigQueryOutputConfiguration { static TableReference getTableReference(Configuration conf) throws IOException { String projectId = getProjectId(conf); String datasetId = getMandatoryConfig(conf, OUTPUT_DATASET_ID); String tableId = getMandatoryConfig(conf, OUTPUT_TABLE_ID); return new TableReference().setProjectId(projectId).setDatasetId(datasetId).setTableId(tableId); }  @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 testGetTableReference() throws IOException { conf.set(BigQueryConfiguration.OUTPUT_PROJECT_ID.getKey(), TEST_PROJECT_ID); conf.set(BigQueryConfiguration.OUTPUT_DATASET_ID.getKey(), TEST_DATASET_ID); conf.set(BigQueryConfiguration.OUTPUT_TABLE_ID.getKey(), TEST_TABLE_ID); TableReference result = BigQueryOutputConfiguration.getTableReference(conf); assertThat(result).isEqualTo(TEST_TABLE_REF); }
@Test public void testGetTableReferenceMissingKey() throws IOException { conf.set(BigQueryConfiguration.OUTPUT_PROJECT_ID.getKey(), TEST_PROJECT_ID); conf.set(BigQueryConfiguration.OUTPUT_DATASET_ID.getKey(), TEST_DATASET_ID); assertThrows(IOException.class, () -> BigQueryOutputConfiguration.getTableReference(conf)); }
@Test public void testGetTableReferenceBackupProjectId() throws IOException { conf.set(BigQueryConfiguration.PROJECT_ID.getKey(), TEST_PROJECT_ID); conf.set(BigQueryConfiguration.OUTPUT_DATASET_ID.getKey(), TEST_DATASET_ID); conf.set(BigQueryConfiguration.OUTPUT_TABLE_ID.getKey(), TEST_PROJECT_ID); BigQueryOutputConfiguration.getTableReference(conf); }