ClickHouse / ClickHouse/ClickHouse
uniqMap ( ? )
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
I was wondering how to create or if there is already a function to do a uniqMap ( which should work in a similar manner to sumMap ).
For example given the dataset
```
date | id | value
2021-01-01 | 1 | 1
2021-01-01 | 1 | 2
2021-01-01 | 1 | 2
2021-01-01 | 2 | 1
2021-01-02 | 1 | 1
```
I can do
```sql
SELECT id, sumMap( array(timestamp), array(1)) as sm
FROM table
GROUP BY id
```
to get something like
```
id | sm
1 | [ ['2021-01-01 ', '2021-01-02 '], [3, 1] ]
2 | [ ['2021-01-01 '], [ 1] ]
```
Now, assume that instead of the sum of times a specific `id` is seen daily, what we want is to count the uniq `value` for this id, per day. So the function will look something like
`uniqMap( array(timestamp), value )`
and the result should be:
```
id | sm
1 | [ ['2021-01-01 ', '2021-01-02 '], [2, 1] ]
2 | [ ['2021-01-01 '], [ 1] ]
```
Contributor guide
Assessment
This issue has not been assessed yet.