A row count can match while the data is wrong. I have seen that on ETL projects for years, and it matters more now that AI assistants write and migrate Glue and PySpark jobs for us.
A model can produce a job that runs clean, finishes green and loads the same number of rows. It can still change a rounding rule, map a status column wrongly, or drop a date partition. Nothing fails. The job is "successful". The first person to notice is usually someone in finance.
I'm Muhammad Usman, a Senior QA Automation Lead and SDET with 10+ years in test automation, and I'm ISTQB CTFL certified. At SprintSynergy, an AI-based QA automation company (AI testing agents plus our QA team), we build agents for the checks that people skip under deadline pressure. This one is qa-core-recon. It proves that a target dataset matches its source after a Glue or PySpark job.
Repo: https://github.com/sprintsynergyio/qa-core-recon
Use AI to build the job. Don't use AI to grade it.
This is the design decision I care about most. In qa-core-recon, no AI model decides pass or fail. The README says so in its first sentence.
I use AI heavily to write and review code. But if the thing that writes the job also judges its output, models can be talked into agreeing. A reconciliation check has to be boring and repeatable: the same two files and the same spec give the same answer every time, and I can explain that answer to an auditor without saying "the model felt it was fine".
So the checks are plain and deterministic:
- row counts, for the whole table and per group (for example per
txn_date) - amount sums, as exact decimals at a scale you set (a float tolerance in the spec is rejected)
- null keys and duplicate keys on each side
- key diff: keys missing from the target, keys that appear only in the target, keys whose row differs
- changed columns: for the keys that differ, which column differs and what the two values were
Each run writes report.json and report.md. Neither has a timestamp, so two runs on the same input produce the same file. The exit code is made for CI: 0 is a match, 1 is a mismatch, 2 is a refusal or a read error.
The demo: five target tables, one source
The repo ships a made-up payments dataset of 200 rows (account, transaction type, amount, currency, date), generated with a fixed seed. No client data is involved.
I ran this in a fresh virtual environment: pip install qa-core-recon==0.1.1 from PyPI, the example specs from a clone of the repo, and Java 17 (Spark needs it):
git clone https://github.com/sprintsynergyio/qa-core-recon.git cd qa-core-recon pip install qa-core-recon==0.1.1 qa-core-recon run --spec examples/demo/specs/match.yaml --out /tmp/recon-match echo $? That prints match and exits 0. Source and target both hold 200 rows, and the amount sum is 110,517.18 on both sides, in every date group.
The interesting part is the four broken targets.
1. Missing rows
missing-rows.yaml drops every target row dated 2024-03-01. The report:
Row Count Mismatch Source rows: 200. Target rows: 160. txn_date=2024-03-01 Source rows: 40. Target rows: 0. This group is missing on the target. Amount Sum Mismatch Source sum: 110517.18. Target sum: 86428.96. Difference: 24088.22. Key Diff Mismatch Missing keys: 40. The first 20 of 40 are listed. A row count alone would catch this one. The useful part is that the report names the day that vanished and the 40 missing txn_id values, so you start at the partition filter.
2. Extra rows
extra-rows.yaml adds three rows on 2024-03-06, a date that doesn't exist in the source. The report shows 203 target rows against 200, a new date group that is missing on the source, an amount difference of 80.75 and exactly three extra keys: TXN900001, TXN900002, TXN900003.
3. Same row count, wrong data
This is the one I built the article around. changed-rows.yaml keeps all 200 keys and changes five rows, TXN000001 to TXN000005. The amount goes up and the transaction type becomes adjustment.
Row Count Match Source rows: 200. Target rows: 200. Amount Sum Mismatch Source sum: 110517.18. Target sum: 110523.43. Difference: 6.25. Key Diff Mismatch Missing keys: 0. Extra keys: 0. Changed keys: 5. Changed Columns Mismatch amount TXN000001 Source: 143.06 Target: 144.31 amount TXN000002 Source: -562.37 Target: -561.12 txn_type TXN000001 Source: payment Target: adjustment txn_type TXN000002 Source: refund Target: adjustment Row count: match. If that were your only check, the job would pass. The amount sum is off by 6.25 out of more than 110,000, too small to notice on a dashboard. The changed-columns check names the columns and shows both values for each key. That's a bug report you can hand to a developer.
4. A systematic shift
sum-mismatch.yaml adds 0.50 to every target amount. The row count matches. The report shows a difference of 100.00 overall, 20.00 in each of the five date groups, and 200 changed keys. When every key changes by the same amount, you're not looking at bad rows. You're looking at a rule, a cast or a rounding step in the transformation.
All five runs behaved as expected: the match exits 0 and the four broken ones exit 1. A run takes about 8 seconds on my machine, including starting Spark locally.
Where it refuses on purpose
A checker that always answers is a trap. Exit code 2 means "I won't compare this", and a refusal still writes a report. Examples:
- An amount that can't be represented exactly at the scale you declared is refused as
inexact-amount. It is not silently rounded. - A tolerance needs a written reason in the spec. If you want to allow a difference, you have to say why, and that reason is part of the file you commit.
- A spec marked as sampled is refused. A sample can't prove a full table matches.
- A source or target path outside the allowlist in the spec is refused.
I like the refusals more than the checks. They stop the tool from giving a green result it hasn't earned.
What it doesn't do yet
I'd rather you hear it from me:
- There has been no live AWS run. Reading CSV, Parquet and Iceberg from S3 is covered by tests that use a mock S3 (moto), and the demo is synthetic. I haven't yet run it against a real bucket and a real Glue output, so I won't claim it has.
- Key diff lists stop at 20 examples. The count is always the full number, but the list is capped.
- Columns you don't name in the spec aren't compared. If a job adds or changes an unlisted column, version 0.1.1 reports a match. I have a fix open for a schema-drift check, and it isn't released yet.
- CSV is comma-separated UTF-8 only. There is no column rename mapping yet and no Glue Data Catalog reader.
- CI runs on Linux with Python 3.11, 3.12 and 3.13 and Java 17. I haven't tested it elsewhere, so I won't tell you it works elsewhere.
It's an early release, version 0.1.1.
How we'd use it on a project
The AI-assisted or hand-written job runs, the recon agent compares source and target in the pipeline, and the exit code gates the next step. A mismatch attaches report.md to the ticket, and our QA team finds the cause. The agent does the repetitive proving. The people do the judging.
If you migrate Glue or PySpark jobs, especially with AI help, try it on a table you know well. Break the target on purpose with a small change in amounts and see whether your current checks notice. If they don't, better to learn that before a release.
If it fails on your data, open an issue with the spec and the report.
