num_vals()

num_vals(StatsSummary1D) RETURNS DOUBLE PRECISION
num_vals(digest tdigest) RETURNS DOUBLE PRECISION

Get the number of values contained in a percentile estimate. This saves space when you need both a count and a percentile estimate as part of a continuous aggregate. You can compute a single percentile estimator by extracting the num_vals from the percentile estimator. You do not need to specify a separate count aggregate.

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

SELECT num_vals(percentile_agg(data))
FROM generate_series(0, 100) data;
num_vals
-----------
       101

Found an issue on this page?

Report an issue!

Related Content