Quantile digest functions#
Data structures#
A quantile digest is a data sketch which stores approximate percentile
information. The Trino 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
qdigests into a singleqdigest.
- value_at_quantile(qdigest(T), quantile) T#
Returns the approximate percentile value from the quantile digest given the number
quantilebetween 0 and 1.
- quantile_at_value(qdigest(T), T) quantile#
Returns the approximate
quantilenumber between 0 and 1 from the quantile digest given an input value. Null is returned if the quantile digest is empty or the input value is outside the range of the quantile digest.
- values_at_quantiles(qdigest(T), quantiles) -> array(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
qdigestwhich is composed of all input values ofx.
- qdigest_agg(x, w) -> qdigest([same as x])
Returns the
qdigestwhich is composed of all input values ofxusing the per-item weightw.
- qdigest_agg(x, w, accuracy) -> qdigest([same as x])
Returns the
qdigestwhich is composed of all input values ofxusing the per-item weightwand maximum error ofaccuracy.accuracymust be a value greater than zero and less than one, and it must be constant for all input rows.