combiner = byFields.aggregate(AggregationCombineFnAdapter.createConstantCombineFn());
@Test @Category(NeedsRunner.class) public void testPerKeyAggregation() { Collection<POJO> elements = ImmutableList.of( new POJO("key1", 1, "value1"), new POJO("key1", 1, "value2"), new POJO("key2", 2, "value3"), new POJO("key2", 2, "value4"), new POJO("key2", 2, "value4")); PCollection<KV<Row, Long>> count = pipeline .apply(Create.of(elements)) .apply(Group.<POJO>byFieldNames("field1").aggregate(Count.combineFn())); Schema keySchema = Schema.builder().addStringField("field1").build(); Collection<KV<Row, Long>> expectedCounts = ImmutableList.of( KV.of(Row.withSchema(keySchema).addValue("key1").build(), 2L), KV.of(Row.withSchema(keySchema).addValue("key2").build(), 3L)); PAssert.that(count).containsInAnyOrder(expectedCounts); pipeline.run(); }