- Categories:
Aggregate functions (Cardinality Estimation) , Window functions (Cardinality Estimation)
HLL_COMBINE¶
Combines (merges) input states into a single output state.
This allows scenarios where HLL_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 HLL_COMBINE, producing the same output state as a single run of HLL_ACCUMULATE over the entire table.
- See also:
Syntax¶
Aggregate function
Window function
For details about the OVER clause, see Window function syntax and usage.
Arguments¶
stateAn expression that contains state information generated by a call to HLL_ACCUMULATE.
Usage notes¶
This function can be used as an aggregate function or a window function.
DISTINCT is supported syntactically, but has no effect.
The output of this function is not fully deterministic. Running this function on the same inputs might return different results at different times. The differences are typically small and are consistent with the fact that the HLL_* functions are approximation functions.
Examples¶
This example shows how to use the three related functions HLL_ACCUMULATE, HLL_ESTIMATE, and HLL_COMBINE.
Create a simple table and data:
Create a table that contains the “state” that represents the current
approximate cardinality information for the table named sequence_demo:
Now create a second table and add data. (In a more realistic situation, the user could have loaded more data into the first table and divided the data into non-overlapping sets based on the time that the data was loaded.)
Get the “state” information for just the new data.
Combine the “state” information for the two batches of rows:
Get the approximate cardinality of the combined set of rows: