CountDistinct implements AggregateFunction<Integer, CountDistinct<T>> { public CountDistinct(String fieldName) { this.fieldName = fieldName; } CountDistinct(String fieldName); @Override void initialize(); @Override void mergeValue(StructuredRecord record); @Override void mergeAggregates(CountDistinct<T> otherAgg); @Override Integer getAggregate(); @Override Schema getOutputSchema();  }
@Test public void testCountDistinct() { Schema schema = Schema.recordOf("cities", Schema.Field.of("city", Schema.of(Schema.Type.STRING))); test(new CountDistinct("city"), schema, "city", 3, Arrays.asList("Mountain View", "Sunnyvale", "Sunnyvale", "Sunnyvale", "RedwoodCity", "RedwoodCity"), new CountDistinct("city")); }