Skill
The guide compara skill gives an agent, as this version prints it.
One native binary. It reads both tables, joins them on the key you name and says what differs, in about a second for ten million rows.
The loop
- Find the key:
compara columns a.csvprints the column names (on Parquet it reads only the footer);compara head a.csv -n 5shows the first rows. - Count:
compara compare a.csv b.csv -k idprints one line of counts and writes nothing. Exit code0: identical;1: they differ;2: an error (its message says what to change);3: duplicate keys, with--fail-on-dups. - See which columns changed:
--json -prints the summary as JSON on standard output (counts on standard error).columns[].changedcounts the rows each column changed in;countshasunchanged,changed,added,removedand the duplicate keys of each side. - See the rows:
--export-dir out/writes the changed, added and removed rows as CSVs, uncapped;-o report.htmlwrites a report a person can open.
compara compare a.csv b.csv -k account_id,txn_id -i updated_at --json -
Options that change the answer
| option | use it when |
|---|---|
-k a,b | the key is several columns: always name all of them |
-i col,col | a column always differs (load time, run id) |
-c col,col | only some columns matter |
--tolerance 0.005 | numbers may differ by rounding; without it 1.0 and 1 differ in CSV |
--trim, --ignore-case | whitespace or case should not count; under --trim a cell of only spaces equals an empty or missing one |
--delimiter ';' | the separator is not found from the header ('\t' for a tab) |
--encoding latin1 | the file is not UTF-8 |
A column only one file has is not compared and does not change the exit
code: a note on standard error names it, and the JSON lists such columns as
meta.only_in_a and meta.only_in_b. Values compare as text in CSV and
JSON; a Parquet column that holds numbers or dates compares by value. A key that appears twice in a file is counted
under the duplicate keys, and its first row takes part in the join.
Safe by default
compare writes only what -o, --json or --export-dir name;
--summary refuses those, for a run that must only read. --exit-zero
exits 0 even when the tables differ, for a job whose output is the report.
Files that are not local
Any file argument can be a URL: s3://bucket/key.parquet, gs://, az://,
https://. Credentials come from each cloud’s own environment variables or
profiles; with none, a public bucket is read unsigned. A directory, a quoted
glob or a prefix is its files read as one table; s3://lake/orders@v41 is
version 41 of a Delta table.
When something fails
Read the error: it names the file, the column or the option, and what to do
(a key column missing from one side lists the columns it has). compara env
prints the CPUs, the memory limit and the temporary directory it sees.
Made from skills/compara/SKILL.md.