Skip to content

approx_count()

Estimate the number of times a value appears from a `CountMinSketch`

Early access 1.8.0

Estimate the number of times a given text value appears in a column.

Given a table of stock data, estimate how many times the symbol AAPL appears:

WITH t AS (
SELECT toolkit_experimental.count_min_sketch(symbol, 0.01, 0.01) AS symbol_sketch
FROM crypto_ticks
)
SELECT toolkit_experimental.approx_count('AAPL', symbol_sketch)
FROM t;

The syntax is:

approx_count (
item TEXT,
agg CountMinSketch
) RETURNS BIGINT
NameTypeDefaultRequiredDescription
itemTEXT-The value you want to estimate occurrences of
aggCountMinSketch-A CountMinSketch object created using count_min_sketch
ColumnTypeDescription
approx_countBIGINTThe estimated number of times item appeared in the sketch