@Udf
  public <T> Map<String, T> union(
      @UdfParameter(description = "first map to union") final Map<String, T> map1,
      @UdfParameter(description = "second map to union") final Map<String, T> map2) {

    final List<Map<String, T>> nonNullInputs =
        Stream.of(map1, map2)
        .filter(Objects::nonNull)
        .collect(Collectors.toList());
    if (nonNullInputs.size() == 0) {
      return null;
    }

    final Map<String, T> output = new HashMap<>();
    nonNullInputs
        .forEach(output::putAll);
    return output;
  }
@Test
  public void shouldReturnEmptyMapFromEmptyMaps() {
    final Map<String, BigDecimal> input1 = Maps.newHashMap();
    final Map<String, BigDecimal> input2 = Maps.newHashMap();
    assertThat(udf.union(input1, input2), equalTo(Collections.EMPTY_MAP));
  }