Skip to content

feat: add percentile_cont, percentile_disc and quantile aliases - #39

Merged
javier merged 1 commit into
masterfrom
nw_percentile_functions
Oct 23, 2026
Merged

javier merged 1 commit into
masterfrom
nw_percentile_functions

Conversation

@nwoolmer

Copy link
Copy Markdown
Contributor

Summary

  • Add percentile_cont, percentile_disc, quantile_cont and quantile_disc to aggregateFunctions in src/grammar/functions.ts, in alphabetical order.
  • Add autocomplete tests: the functions are suggested in a SELECT expression context and not in a WHERE predicate, as for other aggregates.

QuestDB added these functions in questdb/questdb#6680. They also work as window functions (OVER (PARTITION BY ...)). Other functions that are both aggregate and window functions, such as avg and stddev, are listed only under aggregates, so this PR does the same.

🤖 Generated with Claude Code

QuestDB added exact percentile functions in questdb/questdb#6680:
percentile_cont and percentile_disc, plus their quantile_cont and
quantile_disc aliases. They work as aggregates and as whole-partition
window functions. Add them to the aggregate function list so the web
console highlights and autocompletes them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
javier pushed a commit to questdb/documentation that referenced this pull request Oct 23, 2026
## Summary

Documents the exact percentile functions added in questdb/questdb#6680.

- **Aggregate functions**: new `percentile_cont / quantile_cont` and
`percentile_disc / quantile_disc` sections. They cover the
single-percentile and `DOUBLE[]` multi-percentile forms, how each value
is computed (SQL standard / PostgreSQL definitions), return types
(`percentile_disc` returns `LONG` for integer input), NULL handling, and
limitations (`FILL(LINEAR)`, constant fill on the array form, memory use
per group). Both are added to the Statistical aggregates table.
- **`approx_percentile`**: documents the new `DOUBLE[]` form and links
to the exact functions.
- **Window functions**: new `percentile_cont() / percentile_disc()`
reference section (whole-partition only, constant percentile, not in
live views) and a quick-reference row on the overview.
- **Cookbook**: the query times histogram now uses one `percentile_disc`
call over a percentile array with `UNNEST ... WITH ORDINALITY`,
replacing ten `approx_percentile` calls and ten `UNION ALL` branches,
and adds a non-cumulative variant using `lag()`.

All result tables and documented behaviors were checked against a build
of QuestDB master.

## Dependencies

- questdb/sql-parser#39 adds the four function names to web console
highlighting and autocomplete.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@javier
javier merged commit 3a08d45 into master Oct 23, 2026
2 checks passed
@javier javier mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants