You are viewing documentation about an older version (1.12.1). View latest version

snowflake.snowpark.functions.approx_count_distinct

snowflake.snowpark.functions.approx_count_distinct(e: Union[Column, str]) Column[source]

Uses HyperLogLog to return an approximation of the distinct cardinality of the input (i.e. HLL(col1, col2, … ) returns an approximation of COUNT(DISTINCT col1, col2, … )).

Example::
>>> df = session.create_dataframe([[1, 2], [3, 4], [5, 6]], schema=["a", "b"])
>>> df.select(approx_count_distinct("a").alias("result")).show()
------------
|"RESULT"  |
------------
|3         |
------------
Copy