Skip to content

Instantly share code, notes, and snippets.

@ivanpk
Created February 5, 2020 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanpk/b3f70fccfdc35ed604505826b9c61b7e to your computer and use it in GitHub Desktop.
Save ivanpk/b3f70fccfdc35ed604505826b9c61b7e to your computer and use it in GitHub Desktop.
WITH
user_ids AS (
SELECT
'user-id-1' AS user_id
UNION ALL
SELECT
'user-id-1' AS user_id
UNION ALL
SELECT
'user-id-2' AS user_id )
SELECT
HLL_COUNT.init(user_id) as HyperLogLog_Sketch,
HLL_COUNT.extract(HLL_COUNT.init(user_id)) as Distinct_Count_from_HyperLogLog_sketch
FROM
user_ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment