Repository navigation
Commit 8f3ed75
feat: Support Map type in approx_distinct (apache#23526)
## Which issue does this PR close?
- Relates to apache#22989 but does
not close it. More types are coming.
## Rationale for this change
- Support the Arrow types `Map` type for `approx_distinct`
## What changes are included in this PR?
- Enable `HLLAccumulator` and `HllGroupsAccumulator` to support `Map`
- Tests for the non-grouped and grouped path as part of `aggregate.slt`
## Are these changes tested?
Yes and results are compared to DuckDB:
```
D CREATE TABLE approx_distinct_map_test AS SELECT * FROM (VALUES
(1, MAP {'a': 1, 'b': 2}), (1, MAP {'a': 1, 'b': 2}), (1, MAP {'c': 3}),
(2, MAP {'d': 4}), (2, NULL),
(3, NULL), (3, NULL),
(4, MAP {'e': 5})
) AS t(g, m);
D SELECT approx_count_distinct(m) FROM approx_distinct_map_test WHERE g = 1;
┌──────────────────────────┐
│ approx_count_distinct(m) │
│ int64 │
├──────────────────────────┤
│ 2 │
└──────────────────────────┘
D SELECT g, approx_count_distinct(m) FROM approx_distinct_map_test GROUP BY g ORDER BY g;
┌───────┬──────────────────────────┐
│ g │ approx_count_distinct(m) │
│ int32 │ int64 │
├───────┼──────────────────────────┤
│ 1 │ 2 │
│ 2 │ 1 │
│ 3 │ 0 │
│ 4 │ 1 │
└───────┴──────────────────────────┘
D SELECT approx_count_distinct(m) FROM approx_distinct_map_test;
┌──────────────────────────┐
│ approx_count_distinct(m) │
│ int64 │
├──────────────────────────┤
│ 4 │
└──────────────────────────┘
```
## Are there any user-facing changes?
Yes, `approx_distinct` supports now `Map` but no breaking changes.
Co-authored-by: Nuno Faria <[email protected]>1 parent 2d3d5a7 commit 8f3ed75
2 files changed
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
| 845 | + | |
845 | 846 | | |
846 | 847 | | |
847 | 848 | | |
| |||
918 | 919 | | |
919 | 920 | | |
920 | 921 | | |
| 922 | + | |
921 | 923 | | |
922 | 924 | | |
923 | 925 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2095 | 2095 | | |
2096 | 2096 | | |
2097 | 2097 | | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
2098 | 2136 | | |
2099 | 2137 | | |
2100 | 2138 | | |
| |||
0 commit comments