duckdb / duckdb/duckdb-web

Issue found on page 'Aggregate Functions': quantile_cont(x, pos) aggregate function takes value in the range [-1, 1] for pos, needs documentation

Open
#3,306 2 comments 0 reactions 0 assignees View on GitHub
bug functions issue found on page needs documentation
Dominant language
HTML
Stars
301
Forks
597
Avg merge
1d 14h
Merged PRs (30d)
62

Description

The docs for aggregate function quantile_cont(x, pos) read:

> The interpolated pos-quantile of x for 0 <= pos <= 1,

But when we enter an out of range value, the error message tells us the range for `pos `is `[-1, 1]`:

```
select quantile_cont(x, 2)
from range(0,100) as T(x)
```
output:
```
Binder Error: QUANTILE can only take parameters in the range [-1, 1]
```

When I try to use negative values within the range, it appears as if negative values are interpreted to "counting backwards", as if for for 0 < y <=1,

`quantile_cont(x, -y)`
is equivalent to
`quantile_cont(x, 1-y)`

For example:
```
SELECT quantile_cont(x, -0.1) as "q-0.1"
, quantile_cont(x, 1 - 0.1) as "q1-0.1"
, "q-0.1" = "q1-0.1" as "eq"
from range(0, 100) as T(x)
```
output:
```
┌───────────────────┬───────────────────┬─────────┐
│ q-0.1 │ q1-0.1 │ eq │
│ double │ double │ boolean │
├───────────────────┼───────────────────┼─────────┤
│ 89.10000000000001 │ 89.10000000000001 │ true │
└───────────────────┴───────────────────┴─────────┘
```

Page URL: [](https://duckdb.org/docs/sql/functions/aggregates#quantile_contx-pos)

Contributor guide

Open the contributing guide

Research direction

Open the Aggregate Functions documentation at the linked page and inspect the quantile_cont(x, pos) section. Verify the documented range against the shown error and examples, then update the explanation to cover the observed negative-value behavior; done means the page accurately describes valid pos values and their interpretation.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.