num_vals()

  1. num_vals(sketch UddSketch) RETURNS DOUBLE PRECISION
  1. num_vals(digest tdigest) RETURNS DOUBLE PRECISION

Get the number of values contained in a percentile estimate. This is provided in order to save space when both a count and a percentile estimate are required as part of continuous aggregates. You can simply compute a single percentile estimator and do not need to specify a separate count aggregate, just extract the num_vals from the percentile estimator.

Required arguments

NameTypeDescription
sketch / digestUddSketch or tdigestThe percentile estimator to extract the number of values from, usually from a percentile_agg() call.

Returns

ColumnTypeDescription
num_valsDOUBLE PRECISIONThe number of values in the percentile estimate

Sample usage

  1. SELECT num_vals(percentile_agg(data))
  2. FROM generate_series(0, 100) data;
  1. num_vals
  2. -----------
  3. 101