Data quality
SQL checks before publishing a dataset
A practical approach to checking grain, missing values, and currency metadata before a reporting table goes live.
By Ijlal Ansari
Start by writing down what one row means. In the bank ETL output, it represents a bank in one ranking snapshot. A duplicate name is worth investigating at that grain. Over multiple snapshots, the same bank should appear again, so the uniqueness check needs a snapshot key.
Check counts on both sides of the load. For this project, CSV and SQLite are two representations of the same result. Compare their row counts and names, then check that each converted market cap matches the rounded product of USD market cap and the documented exchange rate.
Treat metadata as part of the data contract. A date in a ranking URL identifies the ranking snapshot. The FX file needs a date and source of its own before the table can answer historical questions reliably.
Use a simple grouped query on staging to spot blank and duplicate names before publishing. Record the rule, number of failing rows, and sample failures so the next person can diagnose the batch.
SELECT Name, COUNT(*) AS row_count
FROM Largest_Banks
GROUP BY Name
HAVING Name IS NULL OR TRIM(Name) = '' OR COUNT(*) > 1;