Field note · November 3, 2024

Five minutes with carrier in flight-delays

8,000 rows, 6 distinct values, and the one fact about carrier that changes how you query it.

1 min read ·Data quality ·quality practice

Someone asked what is in carrier on flight-delays, and the honest answer took one query.

8,000 rows, no nulls, 6 distinct values. Two-letter carrier code.

6 values, and they are not evenly spread: AA 21.9%, DL 21.1%, WN 20.7%, UA 17.8%. The largest takes 21.9% 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 carrier order by 1 will, in about a second.

sql
select
  count(*)                  as rows,
  count(carrier)            as present,
  count(*) - count(carrier) as nulls,
  count(distinct carrier)   as distinct_values
from flight_delays;

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 6 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 6 categories reflows without warning. Values arriving is a schema change that no schema check catches.

The grain is one row per scheduled flight, 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.