Hey, As im building a SQL query, im trying to conditionally build a map such that there won't be any keys with null values in it. AFAIK from Calcite there's no native way to do it (other than using case to build the map in different ways, but then i have a lot of key/value pairs so thats not reasonable). I tried to implement it using a flink UDF but failed - i wonder if a table function can return a map since im getting "The Nothing type cannot have a serializer".
Example SQL: Select a, b, c, removeNulls('key1', d, 'key2', e, 'key3', f) AS my_map FROM... My Table Function code is: public class RemoveNullValuesFunction extends TableFunction<Map<String,String>> { public static final String NAME = "removeNulls"; public void eval(String... keyValues) { if (keyValues.length == 0) { collect(Collections.emptyMap()); return; } final List<String> keyValuesList = Arrays.asList(keyValues); Map<String,String> output = Maps.newHashMap(); for (int i = 0; i < keyValuesList.size(); i = i + 2){ final String key = keyValuesList.get(i); final String value = keyValuesList.get(i + 1); if (value != null) output.put(key, value); } collect(output); } @Override public TypeInformation<Map<String, String>> getResultType() { return Types.MAP(Types.STRING(),Types.STRING()); } } I wonder if thats not possible or am i missing something in how the serialization works? Thanks! Shahar -- Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/