BigQueryOutputConfiguration { static Optional<BigQueryTableSchema> getTableSchema(Configuration conf) throws IOException { String fieldsJson = OUTPUT_TABLE_SCHEMA.get(conf, conf::get); if (!Strings.isNullOrEmpty(fieldsJson)) { try { TableSchema tableSchema = BigQueryTableHelper.createTableSchemaFromFields(fieldsJson); return Optional.of(BigQueryTableSchema.wrap(tableSchema)); } catch (IOException e) { throw new IOException("Unable to parse key '" + OUTPUT_TABLE_SCHEMA.getKey() + "'.", e); } } return Optional.empty(); }  @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 testGetTableReferenceSchema() throws IOException { conf.set(BigQueryConfiguration.OUTPUT_TABLE_SCHEMA.getKey(), TEST_TABLE_SCHEMA_STRING); Optional<BigQueryTableSchema> result = BigQueryOutputConfiguration.getTableSchema(conf); assertThat(result.get()).isEqualTo(TEST_TABLE_SCHEMA); }
@Test public void testGetTableReferenceSchemaBadSchema() throws IOException { conf.set(BigQueryConfiguration.OUTPUT_TABLE_SCHEMA.getKey(), TEST_BAD_TABLE_SCHEMA_STRING); assertThrows(IOException.class, () -> BigQueryOutputConfiguration.getTableSchema(conf)); }