octa --diff¶
Compare two files and print what differs. Where
--compare-schemas diffs the column metadata,
--diff diffs the actual rows. Three modes (--diff-mode) trade off
how rows are matched, from coarse whole-row membership to precise
cell-level change detection.
Synopsis¶
| Flag | Required | Meaning |
|---|---|---|
--diff A B |
yes | The two files to compare. Exactly two paths. |
--diff-mode MODE |
no | set (default), ordered, or join. See below. |
--diff-on COLS |
for join only |
Key column(s), comma-separated (e.g. --diff-on id or id,region). |
-f, --format FORMAT |
no | Output format: tsv (default), json, or csv. |
Modes¶
set (default) - whole-row membership¶
Each row is keyed by its whole-row content: every column, in order, rendered to text and joined. A row in A matches a row in B when their keys are equal. Two consequences follow:
- Columns are positional. The two files should share the same column order (and, ideally, names) for the diff to be meaningful. A reordered column set will report everything as changed.
- Cross-format works. Because matching is on rendered values, a CSV
row and a Parquet row with the same logical content match. You can
diff
before.csvagainstafter.parquet.
You learn which whole rows are unique to each side, but not which cells changed within a row.
ordered - positional, cell-level¶
Row i of A is lined up with row i of B and compared cell by cell
over the shared columns. Matched rows that differ are reported with a
changed_columns field naming the differing fields; trailing rows on
the longer side are tagged only_in_a / only_in_b. Use this when the
two files are in the same order and you want to see exactly which
cells moved.
join - key-matched added/removed/changed¶
Rows are matched by the key column(s) you name with --diff-on
(matched by name, so column order is irrelevant). The output keeps file
A's column order and prints B's values under the headings of the same name;
a column B lacks is empty on B's rows. Keys present on
only one side are tagged only_in_a / only_in_b; matched keys whose
non-key cells differ are tagged changed, again with a
changed_columns field. This is the database-style diff: "which ids
were added, removed, or edited".
Output¶
A table whose first column, status, tags each row, followed by the
data columns. For ordered / join a changed_columns column names
the differing fields on a changed row:
status |
Meaning |
|---|---|
only_in_a |
The row appears in FILE_A but not FILE_B. |
only_in_b |
The row appears in FILE_B but not FILE_A. |
changed |
(ordered/join) The matched row differs; see changed_columns. |
Unchanged rows are not printed. A one-line summary (per-mode counts) is written to standard error, so it does not pollute the parseable table on standard output.
Examples¶
What changed between two snapshots¶
$ octa --diff users_v1.csv users_v2.csv
status id name
only_in_a 1 alice
only_in_b 4 dave
shared 2 row(s) - only in A: 1 - only in B: 1
(The shared ... line above is on stderr.)
Which cells changed, row for row¶
$ octa --diff users_v1.csv users_v2.csv --diff-mode ordered
status id name changed_columns
changed 2 bobby name
mode ordered - unchanged: 1 - changed: 1 - only in A: 0 - only in B: 0
Added / removed / edited by key¶
$ octa --diff users_v1.csv users_v2.csv --diff-mode join --diff-on id
status id name changed_columns
changed 2 bobby name
only_in_a 1 alice
only_in_b 4 dave
mode join - unchanged: 1 - changed: 1 - only in A: 1 - only in B: 1
Just the JSON, for piping to jq¶
Tolerance¶
Ordered and join modes can be forgiving. Set mode matches whole rows exactly and refuses every flag below.
| Flag | Effect |
|---|---|
--diff-tolerance N |
Numbers at most N apart count as the same. |
--diff-tolerance-pct P |
Numbers within P percent of the larger value count as the same. |
--diff-time-tolerance SECS |
Dates and times at most SECS seconds apart count as the same. A date counts as midnight. |
--diff-ignore-case |
Text compares without regard to upper and lower case. |
--diff-ignore-spaces |
Text compares trimmed, with runs of spaces as one. |
--diff-ignore-columns A,B |
These columns are left out of the comparison. They still appear in the output. |
A pair of numbers passes if it is within either number tolerance. Case and spaces apply to join keys too; number and time tolerance never do. Negative tolerances are refused.
With any of these set, the summary line on stderr ends with
within tolerance: N, the number of cells that differed in text but
passed.
Exit codes¶
--diff exits 0 on a successful read of both files, regardless of
whether they differ. Non-zero exits map to read failures (file not
found, no reader available).
Past the row cap. This reads every row of the file, however long, because an
answer about part of it would look like an answer about all of it. --rows N
limits that on purpose, and a warning on stderr then says how many rows were read.
See also¶
octa --compare-schemas: diff the column metadata instead of the rows.- MCP
diff_tables: the same feature over MCP. - The GUI Compare view does an interactive row / text diff of two open tabs.
Comparing against a live database table¶
octa --diff orders.csv \
--diff-db warehouse --diff-db-table public.orders \
--diff-mode join --diff-on id
--diff-db CONN names a saved database connection and replaces the
second file, so --diff takes a single positional path. Pair it with
--diff-db-table SCHEMA.TABLE (or CATALOG.SCHEMA.TABLE); an
unqualified name uses the connection's own database.
Side A is the file, side B is the database table, so only_in_a rows
are in your file but not the table. Both sides are read under the normal
row cap.
The GUI equivalent is
Compare with a Database Table; over
MCP it is diff_tables with a b_db object.