@UdafFactory(description = "return the earliest value of a column")
  public static <T> Udaf<T, Struct, T> earliest() {
    return earliest(true);
  }
@Test
  public void shouldCaptureValuesUpToN() {
    // Given:
    final Udaf<Integer, List<Struct>, List<Integer>> udaf = EarliestByOffset.earliest(2);
    udaf.initializeTypeArguments(Collections.singletonList(SqlArgument.of(SqlTypes.INTEGER)));

    // When:
    final List<Struct> res0 = udaf.aggregate(321, new ArrayList<>());
    final List<Struct> res1 = udaf.aggregate(123, res0);

    // Then:
    assertThat(res1, hasSize(2));
    assertThat(res1.get(0).get(VAL_FIELD), is(321));
    assertThat(res1.get(1).get(VAL_FIELD), is(123));
  }