how to check if every unique value of sql_distinct_key has one corresponding value in sql

The problem

If you are getting Non-Unique value/primary key (or sql_distinct_key), value overflow or collision when computing sum error and you've checked that you have a primary key and are also using a sum_distinct with sql_distinct_key, you should check to make sure your sql_distinct_key only has one corresponding value in SQL.

The solution

First check SQL runner to see if you're getting a crazy high number (e.g 1.22222e^32)

If so, run this sql query in SQL runner to see if there are any counts higher than 1.


SELECT
<sql_distinct_key_field>,
<sum_distinct_measure>,
count(*)
FROM demo_db.order_items AS order_items

GROUP BY 1
ORDER BY 3 DESC
LIMIT 100

You can double-check this by going back to the Explore and filtering on the offending sql_distinct_key, choosing the corresponding sql field and seeing how many rows appear in the Explore.

Version history
Last update:
‎08-17-2021 10:04 AM
Updated by: