@Udf
  public <T> List<T> distinct(
      @UdfParameter(description = "Array of values to distinct") final List<T> input) {
    if (input == null) {
      return null;
    }
    final Set<T> distinctVals = Sets.newLinkedHashSetWithExpectedSize(input.size());
    distinctVals.addAll(input);
    return new ArrayList<>(distinctVals);
  }
@SuppressWarnings("unchecked")
  @Test
  public void shouldDistinctArrayOfLists() {
    final List<String> list1 = Arrays.asList("foo", "bar", "baz");
    final List<String> list2 = Arrays.asList("foo", "bar");
    final List<String> list3 = Arrays.asList("foo", "bar", "baz");
    final List<List<String>> result = udf.distinct(Arrays.asList(list1, list2, list3, null));
    assertThat(result, contains(list1, list2, null));
  }