BigQueryUtils { public static SerializableFunction<Row, TableRow> toTableRow() { return ROW_TO_TABLE_ROW; }  @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 testToTableRow_flat() { TableRow row = toTableRow().apply(FLAT_ROW); System.out.println(row); assertThat(row.size(), equalTo(10)); assertThat(row, hasEntry("id", "123")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("name", "test")); assertThat(row, hasEntry("valid", "false")); assertThat(row, hasEntry("binary", "ABCD1234")); }
@Test public void testToTableRow_array() { TableRow row = toTableRow().apply(ARRAY_ROW); assertThat(row, hasEntry("ids", Arrays.asList("123", "124"))); assertThat(row.size(), equalTo(1)); }
@Test public void testToTableRow_row() { TableRow row = toTableRow().apply(ROW_ROW); assertThat(row.size(), equalTo(1)); row = (TableRow) row.get("row"); assertThat(row.size(), equalTo(10)); assertThat(row, hasEntry("id", "123")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("name", "test")); assertThat(row, hasEntry("valid", "false")); assertThat(row, hasEntry("binary", "ABCD1234")); assertThat(row, hasEntry("numeric", "123.456")); }
@Test public void testToTableRow_array_row() { TableRow row = toTableRow().apply(ARRAY_ROW_ROW); assertThat(row.size(), equalTo(1)); row = ((List<TableRow>) row.get("rows")).get(0); assertThat(row.size(), equalTo(10)); assertThat(row, hasEntry("id", "123")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("name", "test")); assertThat(row, hasEntry("valid", "false")); assertThat(row, hasEntry("binary", "ABCD1234")); }
@Test public void testToTableRow_null_row() { TableRow row = toTableRow().apply(NULL_FLAT_ROW); assertThat(row.size(), equalTo(10)); assertThat(row, hasEntry("id", null)); assertThat(row, hasEntry("value", null)); assertThat(row, hasEntry("name", null)); assertThat(row, hasEntry("timestamp_variant1", null)); assertThat(row, hasEntry("timestamp_variant2", null)); assertThat(row, hasEntry("timestamp_variant3", null)); assertThat(row, hasEntry("timestamp_variant4", null)); assertThat(row, hasEntry("valid", null)); assertThat(row, hasEntry("binary", null)); assertThat(row, hasEntry("numeric", null)); }
@Test public void testToTableRow_flat() { TableRow row = toTableRow().apply(FLAT_ROW); System.out.println(row); assertThat(row.size(), equalTo(9)); assertThat(row, hasEntry("id", "123")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("name", "test")); assertThat(row, hasEntry("valid", "false")); assertThat(row, hasEntry("binary", "ABCD1234")); }
@Test public void testToTableRow_row() { TableRow row = toTableRow().apply(ROW_ROW); assertThat(row.size(), equalTo(1)); row = (TableRow) row.get("row"); assertThat(row.size(), equalTo(9)); assertThat(row, hasEntry("id", "123")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("name", "test")); assertThat(row, hasEntry("valid", "false")); assertThat(row, hasEntry("binary", "ABCD1234")); }
@Test public void testToTableRow_array_row() { TableRow row = toTableRow().apply(ARRAY_ROW_ROW); assertThat(row.size(), equalTo(1)); row = ((List<TableRow>) row.get("rows")).get(0); assertThat(row.size(), equalTo(9)); assertThat(row, hasEntry("id", "123")); assertThat(row, hasEntry("value", "123.456")); assertThat(row, hasEntry("name", "test")); assertThat(row, hasEntry("valid", "false")); assertThat(row, hasEntry("binary", "ABCD1234")); }
@Test public void testToTableRow_null_row() { TableRow row = toTableRow().apply(NULL_FLAT_ROW); assertThat(row.size(), equalTo(9)); assertThat(row, hasEntry("id", null)); assertThat(row, hasEntry("value", null)); assertThat(row, hasEntry("name", null)); assertThat(row, hasEntry("timestamp_variant1", null)); assertThat(row, hasEntry("timestamp_variant2", null)); assertThat(row, hasEntry("timestamp_variant3", null)); assertThat(row, hasEntry("timestamp_variant4", null)); assertThat(row, hasEntry("valid", null)); assertThat(row, hasEntry("binary", null)); }