BigQueryUtils { @Experimental(Kind.SCHEMAS) public static TableSchema toTableSchema(Schema schema) { return new TableSchema().setFields(toTableFieldSchema(schema)); }  @Experimental(Kind.SCHEMAS) static TableSchema toTableSchema(Schema schema); @Experimental(Kind.SCHEMAS) static Schema fromTableSchema(TableSchema tableSchema); @Experimental(Kind.SCHEMAS) static org.apache.avro.Schema toGenericAvroSchema(
      String schemaName, List<TableFieldSchema> fieldSchemas); static final BigQueryIO.TypedRead.ToBeamRowFunction<TableRow> tableRowToBeamRow(); static final BigQueryIO.TypedRead.FromBeamRowFunction<TableRow> tableRowFromBeamRow(); static SerializableFunction<Row, TableRow> toTableRow(); static SerializableFunction<T, TableRow> toTableRow(
      SerializableFunction<T, Row> toRow); @Experimental(Kind.SCHEMAS) static Row toBeamRow(GenericRecord record, Schema schema, ConversionOptions options); static TableRow convertGenericRecordToTableRow(
      GenericRecord record, TableSchema tableSchema); static TableRow toTableRow(Row row); @Experimental(Kind.SCHEMAS) static Row toBeamRow(Schema rowSchema, TableRow jsonBqRow); @Experimental(Kind.SCHEMAS) static Row toBeamRow(Schema rowSchema, TableSchema bqSchema, TableRow jsonBqRow); static Object convertAvroFormat(
      FieldType beamFieldType, Object avroValue, BigQueryUtils.ConversionOptions options);  }
@Test public void testToTableSchema_flat() { TableSchema schema = toTableSchema(FLAT_TYPE); assertThat( schema.getFields(), containsInAnyOrder( ID, VALUE, NAME, TIMESTAMP_VARIANT1, TIMESTAMP_VARIANT2, TIMESTAMP_VARIANT3, TIMESTAMP_VARIANT4, VALID, BINARY, NUMERIC)); }
@Test public void testToTableSchema_array() { TableSchema schema = toTableSchema(ARRAY_TYPE); assertThat(schema.getFields(), contains(IDS)); }
@Test public void testToTableSchema_row() { TableSchema schema = toTableSchema(ROW_TYPE); assertThat(schema.getFields().size(), equalTo(1)); TableFieldSchema field = schema.getFields().get(0); assertThat(field.getName(), equalTo("row")); assertThat(field.getType(), equalTo(StandardSQLTypeName.STRUCT.toString())); assertThat(field.getMode(), nullValue()); assertThat( field.getFields(), containsInAnyOrder( ID, VALUE, NAME, TIMESTAMP_VARIANT1, TIMESTAMP_VARIANT2, TIMESTAMP_VARIANT3, TIMESTAMP_VARIANT4, VALID, BINARY, NUMERIC)); }
@Test public void testToTableSchema_array_row() { TableSchema schema = toTableSchema(ARRAY_ROW_TYPE); assertThat(schema.getFields().size(), equalTo(1)); TableFieldSchema field = schema.getFields().get(0); assertThat(field.getName(), equalTo("rows")); assertThat(field.getType(), equalTo(StandardSQLTypeName.STRUCT.toString())); assertThat(field.getMode(), equalTo(Mode.REPEATED.toString())); assertThat( field.getFields(), containsInAnyOrder( ID, VALUE, NAME, TIMESTAMP_VARIANT1, TIMESTAMP_VARIANT2, TIMESTAMP_VARIANT3, TIMESTAMP_VARIANT4, VALID, BINARY, NUMERIC)); }
@Test public void testToTableSchema_flat() { TableSchema schema = toTableSchema(FLAT_TYPE); assertThat( schema.getFields(), containsInAnyOrder( ID, VALUE, NAME, TIMESTAMP_VARIANT1, TIMESTAMP_VARIANT2, TIMESTAMP_VARIANT3, TIMESTAMP_VARIANT4, VALID, BINARY)); }
@Test public void testToTableSchema_row() { TableSchema schema = toTableSchema(ROW_TYPE); assertThat(schema.getFields().size(), equalTo(1)); TableFieldSchema field = schema.getFields().get(0); assertThat(field.getName(), equalTo("row")); assertThat(field.getType(), equalTo(StandardSQLTypeName.STRUCT.toString())); assertThat(field.getMode(), nullValue()); assertThat( field.getFields(), containsInAnyOrder( ID, VALUE, NAME, TIMESTAMP_VARIANT1, TIMESTAMP_VARIANT2, TIMESTAMP_VARIANT3, TIMESTAMP_VARIANT4, VALID, BINARY)); }
@Test public void testToTableSchema_array_row() { TableSchema schema = toTableSchema(ARRAY_ROW_TYPE); assertThat(schema.getFields().size(), equalTo(1)); TableFieldSchema field = schema.getFields().get(0); assertThat(field.getName(), equalTo("rows")); assertThat(field.getType(), equalTo(StandardSQLTypeName.STRUCT.toString())); assertThat(field.getMode(), equalTo(Mode.REPEATED.toString())); assertThat( field.getFields(), containsInAnyOrder( ID, VALUE, NAME, TIMESTAMP_VARIANT1, TIMESTAMP_VARIANT2, TIMESTAMP_VARIANT3, TIMESTAMP_VARIANT4, VALID, BINARY)); }