You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "sam lin (Jira)" <ji...@apache.org> on 2020/09/10 19:02:00 UTC

[jira] [Created] (FLINK-19196) FlinkSQL aggregation function to aggregate array typed column to Map/Multiset

sam lin created FLINK-19196:
-------------------------------

             Summary: FlinkSQL aggregation function to aggregate array typed column to Map/Multiset
                 Key: FLINK-19196
                 URL: https://issues.apache.org/jira/browse/FLINK-19196
             Project: Flink
          Issue Type: New Feature
          Components: Table SQL / API
    Affects Versions: 1.11.1
            Reporter: sam lin


Hi,
 
For FlinkSQL, how do I aggregate an array typed column to a Map/Multiset type? e.g. Given the source events:

userID, arr_types
1, [a, b]
2, [a]
1, [b, c]
 
```
SELECT userID, collect_arr(arr_types) FROM src_table GROUP BY userID
```

Using the above SQL could produce results like:
1, \{a: 1, b: 2, c:1}
2, \{a: 1}

My question is do we have existing UDF to do that?  If not, what is the recommended way to achieve this?  I'm happy to write a UDF if you could provide some code pointers.  Thanks in advance!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)