Last implements SelectionFunction, AggregateFunction<T, Last<T>> { public Last(String fieldName, Schema fieldSchema) { this.fieldName = fieldName; this.fieldSchema = fieldSchema; } Last(String fieldName, Schema fieldSchema); @Override void initialize(); @Override void mergeValue(StructuredRecord record); @Override void mergeAggregates(Last<T> otherAgg); @Nullable @Override T getAggregate(); @Override Schema getOutputSchema(); @Override StructuredRecord select(StructuredRecord record1, StructuredRecord record2);  }
@Test public void testLast() { Schema schema = Schema.recordOf("test", Schema.Field.of("x", Schema.of(Schema.Type.INT))); Last last = new Last("x", Schema.of(Schema.Type.INT)); Assert.assertEquals(Schema.of(Schema.Type.INT), last.getOutputSchema()); test(new Last("x", Schema.of(Schema.Type.INT)), schema, "x", 3, Arrays.asList(1, 2, 3), new Last("x", Schema.of(Schema.Type.INT))); test(new Last("x", Schema.of(Schema.Type.INT)), schema, "x", 3, Collections.singletonList(3), new Last("x", Schema.of(Schema.Type.INT))); test(new Last("x", Schema.of(Schema.Type.INT)), schema, "x", null, Collections.emptyList(), new Last("x", Schema.of(Schema.Type.INT))); }