Field note · September 13, 2024
Five minutes with plan in saas-subscriptions
2,500 rows, 4 distinct values, and the one fact about plan that changes how you query it.
Someone asked what is in plan on saas-subscriptions, and the honest answer took one query.
2,500 rows, no nulls, 4 distinct values. starter, team, business, or enterprise.
4 values, and they are not evenly spread: starter 44.3%, team 32.0%, business 17.7%, enterprise 6.0%. The largest takes 44.3% on its own.
Read the distinct list rather than the distinct count. Casing differences and trailing whitespace produce values that look identical in a report and group separately in SQL, and the count will not show you that — select distinct plan order by 1 will, in about a second.
select
count(*) as rows,
count(plan) as present,
count(*) - count(plan) as nulls,
count(distinct plan) as distinct_values
from saas_subscriptions;Low cardinality, stable values — this is a column you can group by without thinking about it, and a reasonable candidate for a chart facet. Check the distinct list, not just the count, because a stray casing variant hides in the count and shows up in the group-by.
Where this bites: a group-by on this column produces 4 rows today. If it is a column an upstream system can add values to, it produces an unknown number tomorrow, and any dashboard laid out for 4 categories reflows without warning. Values arriving is a schema change that no schema check catches.
The grain is one row per account, which is the context every one of those numbers depends on. None of them survive a change of grain, which is why "profile the column" and "profile the table" are the same job. Full schema, and the CSV, on the dataset page.