@Udf
  public <T> List<T> intersect(
      @UdfParameter(description = "First array of values") final List<T> left,
      @UdfParameter(description = "Second array of values") final List<T> right) {
    if (left == null || right == null) {
      return null;
    }
    final Set<T> intersection = Sets.newLinkedHashSet(left);
    intersection.retainAll(Sets.newHashSet(right));
    return Lists.newArrayList(intersection);
  }
@SuppressWarnings("unchecked")
  @Test
  public void shouldIntersectArraysOfMaps() {
    final Map<String, Integer> map1 = ImmutableMap.of("foo", 1, "bar", 2, "baz", 3);
    final Map<String, Integer> map2 = ImmutableMap.of("foo", 10, "baz", 3);
    final Map<String, Integer> map3 = ImmutableMap.of("foo", 1, "bar", 2, "baz", 3);
    final List<Map<String, Integer>> input1 = Arrays.asList(map1, map2, map3);
    final List<Map<String, Integer>> input2 = Arrays.asList(map2, map3);
    final List<Map<String, Integer>> result = udf.intersect(input1, input2);
    assertThat(result, contains(map1, map2));
  }