Skip to main content
Skip to main content

quantilesPrometheusHistogram

quantilesPrometheusHistogram

Introduced in: v25.10.0

Computes multiple quantiles of a histogram using linear interpolation at different levels simultaneously, taking into account the cumulative value and upper bounds of each histogram bucket.

This function is equivalent to quantilePrometheusHistogram but allows computing multiple quantile levels in a single pass, which is more efficient than calling individual quantile functions.

Syntax

quantilesPrometheusHistogram(level1, level2, ...)(bucket_upper_bound, cumulative_bucket_value)

Parameters

  • level — Levels of quantiles. One or more constant floating-point numbers from 0 to 1. We recommend using level values in the range of [0.01, 0.99]. Float64

Arguments

  • bucket_upper_bound — Upper bounds of the histogram buckets. The highest bucket must have an upper bound of +Inf. Float*
  • cumulative_bucket_value — Cumulative values of the histogram buckets. Values must be monotonically increasing as the bucket upper bound increases. UInt* or Float*

Returned value

Array of quantiles of the specified levels in the same order as the levels were specified. The floating-point type of the result matches the type of bucket_upper_bound. Array(Float32) or Array(Float64)

Examples

Usage example

SELECT quantilesPrometheusHistogram(0.25, 0.5, 0.75)(bucket_upper_bound, cumulative_bucket_value)
FROM VALUES('bucket_upper_bound Float64, cumulative_bucket_value UInt64', (0, 6), (0.5, 11), (1, 14), (inf, 19));
┌─quantilesPrometheusHistogram(0.25, 0.5, 0.75)(bucket_upper_bound, cumulative_bucket_value)─┐
│ [0,0.35,1]                                                                                 │
└────────────────────────────────────────────────────────────────────────────────────────────┘