Skip to content

feat: Support Struct type in approx_distinct#23663

Merged
Jefffrey merged 2 commits into
apache:mainfrom
mkleen:struct_approx_distinct
Jul 17, 2026
Merged

feat: Support Struct type in approx_distinct#23663
Jefffrey merged 2 commits into
apache:mainfrom
mkleen:struct_approx_distinct

Conversation

@mkleen

@mkleen mkleen commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

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:

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           │
├───────┼──────────────────────────┤
│     12 │
│     21 │
│     30 │
│     41 │
└───────┴──────────────────────────┘
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.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Jul 17, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.66%. Comparing base (7ca6e54) to head (e285b01).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23663      +/-   ##
==========================================
- Coverage   80.66%   80.66%   -0.01%     
==========================================
  Files        1086     1086              
  Lines      366694   366694              
  Branches   366694   366694              
==========================================
- Hits       295806   295798       -8     
- Misses      53265    53266       +1     
- Partials    17623    17630       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mkleen
mkleen marked this pull request as ready for review July 17, 2026 09:30
@mkleen mkleen changed the title feat: Add Struct type to approx_distinct feat: Support Struct type for approx_distinct Jul 17, 2026
@mkleen mkleen changed the title feat: Support Struct type for approx_distinct feat: Support Struct type in approx_distinct Jul 17, 2026
@Jefffrey
Jefffrey added this pull request to the merge queue Jul 17, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @mkleen

Merged via the queue into apache:main with commit 78be510 Jul 17, 2026
40 checks passed
@mkleen

mkleen commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@Jefffrey Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants