Skip to main content
Returns the approximation of the p-th percentile with weight. The value of p is between 0 and 1, and it can be a single value or an array. PERCENTILE_APPROX_WEIGHT is a weighted version of PERCENTILE_APPROX that allows users to specify a weight (a constant value or numeric column) for each input value. This function uses fixed-size memory, so less memory can be used for columns with high cardinality. It also can be used to calculate statistics such as tp99.

Syntax

  • expr: The column for which to calculate the percentile.
  • p: The percentile value, which must be a DOUBLE in the range [0, 1], or an ARRAY<DOUBLE> where each element is in the range [0, 1]. For example, 0.99 represents the 99th percentile.
  • weight : Weight column. It must be a positive constant number or column.
  • compression : (Optional) Compression ratio. Range: [2048, 10000]. The larger the value, the higher the precision, the larger the memory consumption, and the longer the calculation time. If this parameter is not specified or the value is beyond the range of [2048, 10000], the default value 10000 is used.

Examples

text

Keywords

PERCENTILE_APPROX_WEIGHT,PERCENTILE_APPROX,PERCENTILE,APPROX