@SuppressWarnings("unchecked")
  @Udf
  public <T> List<T> union(
      @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> combined = Sets.newLinkedHashSet(left);
    combined.addAll(right);
    return (List<T>) Arrays.asList(combined.toArray());
  }
@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);
    final List<Map<String, Integer>> input2 = Arrays.asList(map2, map3);
    final List<Map<String, Integer>> result = udf.union(input1, input2);
    assertThat(result, contains(map1, map2));
  }