Skip to content

fix(docs): Khyperloglog uniqueness_distribution default behavior#26957

Merged
HeidiHan0000 merged 2 commits intoprestodb:masterfrom
HeidiHan0000:export-D90611985
Jan 15, 2026
Merged

fix(docs): Khyperloglog uniqueness_distribution default behavior#26957
HeidiHan0000 merged 2 commits intoprestodb:masterfrom
HeidiHan0000:export-D90611985

Conversation

@HeidiHan0000
Copy link
Copy Markdown
Contributor

@HeidiHan0000 HeidiHan0000 commented Jan 13, 2026

Summary:
The docs mention that a default value of 256 will be used as the default value for histogramSize if omitted. The KHyperLogLog.java class correctly reflects this behavior. However, in KHyperLogLogFunctions.java, in the one parameter version of the function uniqueness_distribution, we see that the size fo the minhash is passed in, so the default value in the class itself would never actually get used.

For instance, a query like

WITH test_data AS (
    SELECT
        KHYPERLOGLOG_AGG(join_key, uii) AS khll
    FROM (
        VALUES
            (5, 100),
            (1, 200)
    ) AS t(join_key, uii)
)
SELECT
    UNIQUENESS_DISTRIBUTION(khll) AS dist_map
FROM test_data

returns

{
  "1": 1,
  "2": 0
}

and not

{
  "1": 1,
  "2": 0,
  "3": 0,
  "4": 0,
...}

Updating the doc to represent the actual behavior.

Alternatively, we can change the function implementation to use the default value.

Differential Revision: D90611985

== NO RELEASE NOTE ==

Summary:
The docs mention that a default value of 256 will be used as the default value for histogramSize if omitted. The KHyperLogLog.java class correctly reflects this behavior. However, in KHyperLogLogFunctions.java, in the one parameter version of the function uniqueness_distribution, we see that the size fo the minhash is passed in, so the default value in the class itself would never actually get used.

For instance, a query like
```
WITH test_data AS (
    SELECT
        KHYPERLOGLOG_AGG(join_key, uii) AS khll
    FROM (
        VALUES
            (5, 100),
            (1, 200)
    ) AS t(join_key, uii)
)
SELECT
    UNIQUENESS_DISTRIBUTION(khll) AS dist_map
FROM test_data
```
returns
```
{
  "1": 1,
  "2": 0
}
```
and not
```
{
  "1": 1,
  "2": 0,
  "3": 0,
  "4": 0,
...}
```

Updating the doc to represent the actual behavior.

Alternatively, we can change the function implementation to use the default value.

Differential Revision: D90611985
@HeidiHan0000 HeidiHan0000 requested review from a team, elharo and steveburnett as code owners January 13, 2026 19:28
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Jan 13, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Jan 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates KHyperLogLog documentation to align the described default behavior of UNIQUENESS_DISTRIBUTION with its actual implementation, which does not apply the 256 default histogram size when called with a single argument.

File-Level Changes

Change Details Files
Align KHyperLogLog uniqueness_distribution documentation with the current implementation behavior.
  • Clarify that the one-argument UNIQUENESS_DISTRIBUTION function uses the minhash size from the input sketch rather than a default histogram size of 256.
  • Adjust examples or descriptive text so that the documented output shape matches the actual query result when histogramSize is omitted.
  • Remove or correct any mention of an unconditional default histogramSize of 256 for the single-parameter variant.
presto-docs/src/main/sphinx/functions/khyperloglog.rst

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `presto-docs/src/main/sphinx/functions/khyperloglog.rst:59` </location>
<code_context>
-    Returns the uniqueness histogram with the given amount of buckets. If omitted,
-    the value defaults to 256. All ``uniqueness`` values greater than ``histogramSize`` are
-    accumulated in the last bucket.
+    Returns the uniqueness histogram with the given amount of buckets, ``histogramSize``.
+    All ``uniqueness`` values greater than ``histogramSize`` are accumulated
+    in the last bucket.
</code_context>

<issue_to_address>
**nitpick (typo):** Consider changing "amount of buckets" to "number of buckets" for grammatical correctness.

Since "buckets" are countable, "number of buckets" is the grammatically correct phrasing here.

```suggestion
    Returns the uniqueness histogram with the given number of buckets, ``histogramSize``.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

Suggest accepting the sourcery-ai suggestion to change "the given amount of buckets" to "the given number of buckets". Nothing else, looks good in a local doc build. Thank you!

@github-project-automation github-project-automation bot moved this from 🆕 Unprioritized to 🏗 In progress in Presto Documentation Jan 13, 2026
@steveburnett
Copy link
Copy Markdown
Contributor

If you have time, consider adding

== NO RELEASE NOTE ==

with a row of triple `s above and below, to the PR description to pass the (not-required) failing CI check.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull updated branch, new local doc build, looks good. Thanks!

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Presto Documentation Jan 13, 2026
@HeidiHan0000 HeidiHan0000 merged commit b64af1e into prestodb:master Jan 15, 2026
78 of 79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants