# Quantile Digest Functions

openLooKeng implements the `approx_percentile` function with the quantile digest data structure. The underlying data structure, qdigest, is exposed as a data type in openLooKeng, and can be created, queried and stored separately from `approx_percentile`.

## Data Structures

A quantile digest is a data sketch which stores approximate percentile information. The openLooKeng type for this data structure is called `qdigest`, and it takes a parameter which must be one of `bigint`, `double` or `real` which represent the set of numbers that may be ingested by the `qdigest`. They may be merged without losing precision, and for storage and retrieval they may be cast to/from `VARBINARY`.

## Functions

merge(qdigest) -> qdigest

Merges all input `qdigest`s into a single `qdigest`.

value_at_quantile(qdigest(T), quantile) -> T

Returns the approximate percentile values from the quantile digest given the number `quantile` between 0 and 1.

values_at_quantiles(qdigest(T), quantiles) -> T

Returns the approximate percentile values as an array given the input quantile digest and array of values between 0 and 1 which represent the quantiles to return.

qdigest_agg(x) -> qdigest<[same as x]>

Returns the `qdigest` which is composed of all input values of `x`.

qdigest_agg(x, w) -> qdigest<[same as x]>

Returns the `qdigest` which is composed of all input values of `x` using the per-item weight `w`.

qdigest_agg(x, w, accuracy) -> qdigest<[same as x]>

Returns the `qdigest` which is composed of all input values of `x` using the per-item weight `w` and maximum error of `accuracy`. `accuracy` must be a value greater than zero and less than one, and it must be constant for all input rows.

## 有奖捉虫

0/500

### 存在的问题

● 拼写，格式，无效链接等错误；

● 技术原理、功能、规格等描述和软件不一致，存在错误；

● 原理图、架构图等存在错误；

● 版本号不匹配：文档版本或内容描述和实际软件不一致；

● 对重要数据或系统存在风险的操作，缺少安全提示；

● 排版不美观，影响阅读；

● 描述存在歧义；

● 图形、表格、文字等晦涩难懂；

● 逻辑不清晰，该分类、分项、分步骤的没有给出；

● 很难通过搜索引擎，openLooKeng官网，相关博客找到所需内容；

● 命令、命令参数等错误；

● 命令无法执行或无法完成对应功能；

● 关键步骤错误或缺失，无法指导用户完成任务，比如安装、配置、部署等；

● 逻辑不清晰，该分类、分项、分步骤的没有给出

● 图形、表格、文字等晦涩难懂

● 缺少必要的前提条件、注意事项等；

● 描述存在歧义

0/500