docs: missing optional error_rate parameter in APPROX_COUNT_DISTINCT documentation

Open Beginner friendly
#3,296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Quiet
Tech stack
sql
Domain
documentation

Research direction

Read the current documentation in docs/en/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-approx-count-distinct.md and compare it with the signature details in src/query/functions/src/aggregates/aggregate_approx_count_distinct.rs. Update the documented syntax, explain the error-rate and precision tradeoff, and add an example using APPROX_COUNT_DISTINCT(user_id, 0.05).

Written by the indexing model from the issue text.

Description

documentation

What's Missing

The APPROX_COUNT_DISTINCT aggregate function accepts an optional error rate parameter that controls the precision of the HyperLogLog estimation, but the current documentation only shows the single-argument form.

Source File

/workspace/databend/src/query/functions/src/aggregates/aggregate_approx_count_distinct.rs

What It Does

The function signature is:

APPROX_COUNT_DISTINCT(<expr> [, <error_rate>])
-- or equivalently:
APPROX_COUNT_DISTINCT(<error_rate>)(<expr>)

When error_rate is provided (a float64 value), the precision parameter p is computed as:

p = ceil(log2((1.04 / error_rate)^2))

and clamped to the range [4, 14]. The default precision is p = 14 (approximately 0.81% error rate). A higher error rate means fewer bits of precision and faster computation.

Current Documentation

/workspace/databend-docs/docs/en/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-approx-count-distinct.md

The current doc only documents:

APPROX_COUNT_DISTINCT(<expr>)

Suggested Doc Location

/workspace/databend-docs/docs/en/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-approx-count-distinct.md

The doc should be updated to show the optional error_rate parameter, explain the precision/accuracy tradeoff, and include an example using a custom error rate such as APPROX_COUNT_DISTINCT(user_id, 0.05).

Dominant language
TypeScript
Stars
17
Forks
44
Avg merge
2d 7m
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databendlabs/databend-docs

All issues in databendlabs/databend-docs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.