use of com.google.cloud.teleport.bigtable.BigtableToAvro.BigtableToAvroFn in project DataflowTemplates by GoogleCloudPlatform.
the class BigtableToAvroTest method applyBigtableToAvroFn.
@Test
public void applyBigtableToAvroFn() throws Exception {
Row bigtableRow1 = createBigtableRow("row1");
bigtableRow1 = upsertBigtableCell(bigtableRow1, "family1", "column1", 1, "value1");
bigtableRow1 = upsertBigtableCell(bigtableRow1, "family1", "column1", 2, "value2");
bigtableRow1 = upsertBigtableCell(bigtableRow1, "family1", "column2", 1, "value3");
bigtableRow1 = upsertBigtableCell(bigtableRow1, "family2", "column1", 1, "value4");
Row bigtableRow2 = createBigtableRow("row2");
bigtableRow2 = upsertBigtableCell(bigtableRow2, "family2", "column2", 1, "value2");
final List<Row> bigtableRows = ImmutableList.of(bigtableRow1, bigtableRow2);
BigtableRow avroRow1 = createAvroRow("row1");
addAvroCell(avroRow1, "family1", "column1", 1, "value1");
// Expect a new cell due to a different timestamp of "2".
addAvroCell(avroRow1, "family1", "column1", 2, "value2");
// Expect a new cell due to a different column of "column2".
addAvroCell(avroRow1, "family1", "column2", 1, "value3");
// Expect a new cell due to a different family of "family2".
addAvroCell(avroRow1, "family2", "column1", 1, "value4");
BigtableRow avroRow2 = createAvroRow("row2");
addAvroCell(avroRow2, "family2", "column2", 1, "value2");
final List<BigtableRow> expectedAvroRows = ImmutableList.of(avroRow1, avroRow2);
PCollection<BigtableRow> avroRows = pipeline.apply("Create", Create.of(bigtableRows)).apply("Transform to Avro", MapElements.via(new BigtableToAvroFn()));
PAssert.that(avroRows).containsInAnyOrder(expectedAvroRows);
pipeline.run();
}
Aggregations