HLL function - Amazon Redshift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

HLL function

The HLL function returns the HyperLogLog cardinality of the input expression values. The HLL function works with any data types except the HLLSKETCH data type. The HLL function ignores NULL values. When there are no rows in a table or all rows are NULL, the resulting cardinality is 0.


HLL (aggregate_expression)



Any valid expression that provides the value to an aggregate, such as a column name. This function supports any data type as input except HLLSKETCH, GEOMETRY, GEOGRAPHY, and VARBYTE.

Return type

The HLL function returns a BIGINT or INT8 value.


The following example returns the cardinality of column an_int in table a_table.

CREATE TABLE a_table(an_int INT); INSERT INTO a_table VALUES (1), (2), (3), (4); SELECT hll(an_int) AS cardinality FROM a_table; cardinality ------------- 4