Skip to content

feat: support HLL sketch functions - #24611

Merged
mergify[bot] merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/issue-23356-hll
May 27, 2026
Merged

feat: support HLL sketch functions#24611
mergify[bot] merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/issue-23356-hll

Conversation

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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 from binary/varbinary/blob inputs.
  • hll_cardinality(sketch) returns the estimated cardinality of a serialized HLL sketch.

The current implementation stores HLL sketches as varbinary/blob values and does not add a dedicated SQL HLL type yet.

Validation:

  • git diff --check
  • CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/colexec/aggexec -count=1
  • CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/plan/function -count=1
  • CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/plan -run '^$' -count=1
  • CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/sql/colexec/aggexec ./pkg/sql/plan/function -run 'TestHll|TestApproxCount|Test_funids' -count=1
  • Built mo-service locally and ran test/distributed/cases/function/func_hll.sql against a temporary MatrixOne service on port 16001; valid HLL queries returned 3, 2, 2, 3, 0, NULL, and invalid sketch input returned invalid input: invalid HLL sketch: too short binary.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/feature label May 26, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the queued label May 27, 2026
@mergify

mergify Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-05-27 09:26 UTC · Rule: main
  • Checks passed · in-place
  • Merged2026-05-27 10:59 UTC · at 96bbe0f9043b9d01967b86b1fd9c48e1487c3418 · squash

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
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage

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

Labels

kind/feature size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants