feat: support HLL sketch functions - #24611
Merged
mergify[bot] merged 5 commits intoMay 27, 2026
Merged
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
approved these changes
May 27, 2026
XuPeng-SH
left a comment
Contributor
There was a problem hiding this comment.
Reviewed from multiple angles. The HLL agg/scalar wiring is complete, NULL/invalid-sketch semantics are covered, and I did not find a blocking correctness issue.
aunjgr
approved these changes
May 27, 2026
heni02
approved these changes
May 27, 2026
Contributor
Merge Queue Status
This pull request spent 1 hour 33 minutes 3 seconds in the queue, including 1 hour 32 minutes 29 seconds running CI. Required conditions to merge
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #23356
What this PR does / why we need it:
This PR adds HyperLogLog sketch functions for approximate distinct counting:
hll_add_agg(expr)builds a serialized HLL sketch from non-NULL input values.hll_merge_agg(sketch)merges serialized HLL sketches frombinary/varbinary/blobinputs.hll_cardinality(sketch)returns the estimated cardinality of a serialized HLL sketch.The current implementation stores HLL sketches as
varbinary/blobvalues and does not add a dedicated SQLHLLtype yet.Validation:
git diff --checkCGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/colexec/aggexec -count=1CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/plan/function -count=1CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/plan -run '^$' -count=1CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/colexec/aggexec ./pkg/sql/plan/function -run 'TestHll|TestApproxCount|Test_funids' -count=1mo-servicelocally and rantest/distributed/cases/function/func_hll.sqlagainst a temporary MatrixOne service on port16001; valid HLL queries returned3,2,2,3,0,NULL, and invalid sketch input returnedinvalid input: invalid HLL sketch: too short binary.