Repository navigation
Commit 1bbae17
feat: Support Struct type in approx_distinct (apache#23663)
## 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 type `Struct` type for `approx_distinct`
## What changes are included in this PR?
- Enable `HLLAccumulator` and `HllGroupsAccumulator` to support `Struct`
- Tests for the non-grouped and grouped path as part of `aggregate.slt`
## Are these changes tested?
Yes and results are compared to DuckDB:
```sql
D CREATE TABLE approx_distinct_struct_test AS SELECT * FROM (VALUES
(1, {'a': 1, 'b': 2}), (1, {'a': 1, 'b': 2}), (1, {'a': 3, 'b': 3}),
(2, {'a': 4, 'b': 4}), (2, NULL),
(3, NULL), (3, NULL),
(4, {'a': 5, 'b': 5})
) AS t(g, s);
D SELECT approx_count_distinct(s) FROM approx_distinct_struct_test WHERE g = 1;
┌──────────────────────────┐
│ approx_count_distinct(s) │
│ int64 │
├──────────────────────────┤
│ 2 │
└──────────────────────────┘
D SELECT g, approx_count_distinct(s) FROM approx_distinct_struct_test GROUP BY g ORDER BY g;
┌───────┬──────────────────────────┐
│ g │ approx_count_distinct(s) │
│ int32 │ int64 │
├───────┼──────────────────────────┤
│ 1 │ 2 │
│ 2 │ 1 │
│ 3 │ 0 │
│ 4 │ 1 │
└───────┴──────────────────────────┘
D SELECT approx_count_distinct(s) FROM approx_distinct_struct_test;
┌──────────────────────────┐
│ approx_count_distinct(s) │
│ int64 │
├──────────────────────────┤
│ 4 │
└──────────────────────────┘
```
## Are there any user-facing changes?
Yes, `approx_distinct` supports now `Struct` but no breaking changes.1 parent b1fb639 commit 1bbae17
2 files changed
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
| 846 | + | |
846 | 847 | | |
847 | 848 | | |
848 | 849 | | |
| |||
920 | 921 | | |
921 | 922 | | |
922 | 923 | | |
| 924 | + | |
923 | 925 | | |
924 | 926 | | |
925 | 927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2133 | 2133 | | |
2134 | 2134 | | |
2135 | 2135 | | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
2136 | 2174 | | |
2137 | 2175 | | |
2138 | 2176 | | |
| |||
0 commit comments