Quantiles functions in the Apache DataSketches DuckDB extension
Function category
Quantiles
14 functionsClassic [mergeable quantile sketch](https://datasketches.apache.org/docs/Quantiles/ClassicQuantilesSketch.html) from the original DataSketches paper. Solid general-purpose choice supporting all numeric types; KLL is now preferred for new projects.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
INTEGER
|
Mode Positional | Description |
Argument
col1
|
Type
INTEGER | DOUBLE | UINTEGER | …
20 concrete typesBIGINTDOUBLEFLOATINTEGERSMALLINTTINYINTUBIGINTUINTEGERUSMALLINTUTINYINTsketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Return type varies by input — 10 concrete types
sketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
Description
Aggregate input values into the classic mergeable quantiles sketch from the original DataSketches paper. Solid general-purpose choice supporting all numeric input types; for new projects prefer datasketch_kll, which gives the same merge semantics with better accuracy/size trade-off.
SELECT datasketch_quantiles(k, data);
Related functions
- datasketch_quantiles_quantile() — Approximate quantile at a given rank from a classic Quantiles sketch
- datasketch_quantiles_rank() — Approximate rank of a value within the classic Quantiles sketch
- datasketch_quantiles_cdf() — Return the Cumulative Distribution Function (CDF) of the sketch for a series of points
- datasketch_quantiles_pmf() — Return the Probability Mass Function (PMF) of the sketch for a series of points
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Argument
col1
|
Type
<numeric>[]
10 concrete typesBIGINT[]DOUBLE[]FLOAT[]INTEGER[]SMALLINT[]TINYINT[]UBIGINT[]UINTEGER[]USMALLINT[]UTINYINT[]
|
Mode Positional | Description |
Argument
col2
|
Type
BOOLEAN
|
Mode Positional | Description |
Return type varies by input — 10 concrete types
BIGINT[]DOUBLE[]FLOAT[]INTEGER[]SMALLINT[]TINYINT[]UBIGINT[]UINTEGER[]USMALLINT[]UTINYINT[]
Description
Return the Cumulative Distribution Function (CDF) of the sketch for a series of points
SELECT datasketch_quantiles_cdf(sketch, points, inclusive);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Argument
col1
|
Type
BOOLEAN
|
Mode Positional | Description |
Argument
col2
|
Type
BOOLEAN
|
Mode Positional | Description |
Description
Return a description of this sketch
SELECT datasketch_quantiles_describe(sketch, include_levels, include_items);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Description
Return a boolean indicating if the sketch is empty
SELECT datasketch_quantiles_is_empty(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Description
Return a boolean indicating if the sketch is in estimation mode
SELECT datasketch_quantiles_is_estimation_mode(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Description
Return the value of K for this sketch
SELECT datasketch_quantiles_k(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Return type varies by input — 10 concrete types
BIGINTDOUBLEFLOATINTEGERSMALLINTTINYINTUBIGINTUINTEGERUSMALLINTUTINYINT
Description
Return the maxium item in the sketch
SELECT datasketch_quantiles_max_item(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Return type varies by input — 10 concrete types
BIGINTDOUBLEFLOATINTEGERSMALLINTTINYINTUBIGINTUINTEGERUSMALLINTUTINYINT
Description
Return the minimum item in the sketch
SELECT datasketch_quantiles_min_item(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Description
Return the number of items contained in the sketch
SELECT datasketch_quantiles_rank(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Argument
col1
|
Type
BOOLEAN
|
Mode Positional | Description |
Description
Return the normalized rank error of the sketch
SELECT datasketch_quantiles_normalized_rank_error(sketch, is_pmf);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Description
Return the number of retained items in the sketch
SELECT datasketch_quantiles_num_retained(sketch);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Argument
col1
|
Type
<numeric>[]
10 concrete typesBIGINT[]DOUBLE[]FLOAT[]INTEGER[]SMALLINT[]TINYINT[]UBIGINT[]UINTEGER[]USMALLINT[]UTINYINT[]
|
Mode Positional | Description |
Argument
col2
|
Type
BOOLEAN
|
Mode Positional | Description |
Return type varies by input — 10 concrete types
BIGINT[]DOUBLE[]FLOAT[]INTEGER[]SMALLINT[]TINYINT[]UBIGINT[]UINTEGER[]USMALLINT[]UTINYINT[]
Description
Return the Probability Mass Function (PMF) of the sketch for a series of points
SELECT datasketch_quantiles_pmf(sketch, points, inclusive);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Argument
col1
|
Type
DOUBLE
|
Mode Positional | Description |
Argument
col2
|
Type
BOOLEAN
|
Mode Positional | Description |
Return type varies by input — 10 concrete types
BIGINTDOUBLEFLOATINTEGERSMALLINTTINYINTUBIGINTUINTEGERUSMALLINTUTINYINT
Description
Approximate quantile at a given rank from a classic Quantiles sketch.
SELECT datasketch_quantiles_rank(sketch, rank, inclusive);
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
<sketch>
10 concrete typessketch_quantiles_bigintsketch_quantiles_doublesketch_quantiles_floatsketch_quantiles_integersketch_quantiles_smallintsketch_quantiles_tinyintsketch_quantiles_ubigintsketch_quantiles_uintegersketch_quantiles_usmallintsketch_quantiles_utinyint
|
Mode Positional | Description |
Argument
col1
|
Type
<numeric>
10 concrete typesBIGINTDOUBLEFLOATINTEGERSMALLINTTINYINTUBIGINTUINTEGERUSMALLINTUTINYINT
|
Mode Positional | Description |
Argument
col2
|
Type
BOOLEAN
|
Mode Positional | Description |
Description
Approximate rank of a value within the classic Quantiles sketch.
SELECT datasketch_quantiles_rank(sketch, item, inclusive);