Quantiles (DoublesSketch) Functions
Classic quantiles sketch (DoublesSketch) — the original DataSketches quantile algorithm. Provides the same functionality as KLL but with different trade-offs. For new projects, prefer KLL which is more space-efficient.
Table of contents
Aggregation Functions
ds_quantiles_sketch
ds_quantiles_sketch(value) -> varbinary
ds_quantiles_sketch(value, k) -> varbinary
| Parameter | Type | Description |
|---|---|---|
value | DOUBLE, REAL, or BIGINT | Numeric values |
k | INTEGER | Accuracy parameter (default 128) |
ds_quantiles_union
ds_quantiles_union(sketch) -> varbinary
Scalar Functions
ds_quantiles_quantile
ds_quantiles_quantile(sketch, rank) -> double
ds_quantiles_quantiles
ds_quantiles_quantiles(sketch, ranks) -> array(double)
ds_quantiles_rank
ds_quantiles_rank(sketch, value) -> double
ds_quantiles_cdf
ds_quantiles_cdf(sketch, splitPoints) -> array(double)
ds_quantiles_pmf
ds_quantiles_pmf(sketch, splitPoints) -> array(double)
ds_quantiles_n
ds_quantiles_n(sketch) -> bigint
ds_quantiles_k
ds_quantiles_k(sketch) -> bigint
ds_quantiles_stringify
ds_quantiles_stringify(sketch) -> varchar
KLL vs Quantiles
| Property | KLL | Quantiles (DoublesSketch) |
|---|---|---|
| Space efficiency | Better | Larger for same accuracy |
| Merge speed | Similar | Similar |
| Algorithm | Near-optimal | Classic |
| Recommendation | Preferred | Legacy compatibility |
All functions behave identically to their ds_kll_* counterparts. See KLL Sketch for detailed parameter descriptions and examples.