Reconciliation SQL for source vs warehouse
Generate matching SQL for both sides: row counts, id sums and optional checksums per id bucket, then paste the results to see exactly which ranges differ.
Generated SQL
Run query 1 on both sides and paste the results below. Query 3 lists missing id ranges inside the first bucket that doesn't match below.
Compare the results
Paste the rows from query 1 (CSV or tab-separated, with or without a header). The comparison runs in your browser.
Want this running every day, with alerts?
My pipeline audit reconciles your warehouse against the source and leaves a daily check running. From $480.
The maths, in the open
Why buckets
A single COUNT(*) tells you something is wrong, but not where. Splitting the primary key into ranges (id ÷ bucket size) and comparing count, min, max and sum of ids per range narrows a problem down to one bucket. Then query 3 lists the exact missing id ranges inside it. This is the same approach I use for daily reconciliation on a production CDC platform.
What each column catches
row_count catches missing rows and duplicates. id_sum catches cases where the count matches but different ids are present. row_hash_sum (optional) catches changed values. It hashes the chosen columns with MD5, takes the first 8 hex digits as a number, and sums them. Each dialect uses its own functions to produce the same number.
Getting checksums to agree across databases
Checksums only match if each value turns into the same text on both sides. That works for integers and plain text. Timestamps, decimals, floats and booleans often print differently between databases, so leave them out or cast them to a fixed format in both queries. NULL becomes ~ on both sides.
Rows still in flight
With CDC, the newest rows may not have arrived yet. Use a cutoff column and value a few minutes in the past, or compare id ranges that have stopped changing.
Questions about this tool
Does this work for ClickHouse ReplacingMergeTree tables?
Yes. Tick FINAL so replayed versions of a row count once, and set the deleted-flag column if you soft-delete. Without FINAL, recent duplicates that haven't merged yet will show up as extra rows.
My primary key isn't an integer. What now?
Bucketing needs a numeric key. For UUID or string keys, bucket by a hash of the key, or by a date column, and compare per day. Email me if you want help adapting it.
Is any of my data sent anywhere?
No. The SQL is generated in your browser, and the comparison of pasted results runs in your browser too.
Can you set this up to run automatically?
Yes. A scheduled reconciliation job with alerts is part of my pipeline audit and CDC packages.
One senior engineer, start to finish
I'm Danish Rajpoot (Muhammad Danish Ishfaq), a data architect and principal data engineer with nearly 9 years on data platforms and a master's in computer science from the University of Eastern Finland. I do the work myself and write the handover so your team can run it without me.