APPROX_TOP_K_COMBINE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow function syntax and usage

Combines (merges) input states into a single output state. This allows scenarios where APPROX_TOP_K_ACCUMULATE is run over horizontal partitions of the same table, producing an algorithm state for each table partition. These states can later be combined using APPROX_TOP_K_COMBINE, producing the same output state as a single run of APPROX_TOP_K_ACCUMULATE over the entire table.

Syntax

supportedpartialnot supportednot scored

APPROX_TOP_K_COMBINE( <state> [ , <counters> ] )

Parameters

NameRequiredDescription
staterequiredAn expression that contains state information generated by a call to APPROX_TOP_K_ACCUMULATE.
countersrequiredThis is the maximum number of distinct values that can be tracked at a time during the estimation process. For example, if counters is set to 100000, then the algorithm tracks 100,000 distinct values, attempting to keep the 100,000 most frequent values. The maximum number of counters is 100000 (100,000).

Returns

This returns information about the “state” of the top K calculation. This state information is not usually useful by itself, but can be passed to the function APPROX_TOP_K_ESTIMATE.

Usage notes

See also

Referenced by