rowdelta 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. rowdelta-0.1.0/.github/ISSUE_TEMPLATE/bug.yml +22 -0
  2. rowdelta-0.1.0/.github/ISSUE_TEMPLATE/config.yml +1 -0
  3. rowdelta-0.1.0/.github/ISSUE_TEMPLATE/feature.yml +15 -0
  4. rowdelta-0.1.0/.github/dependabot.yml +8 -0
  5. rowdelta-0.1.0/.github/workflows/ci.yml +87 -0
  6. rowdelta-0.1.0/.github/workflows/publish.yml +44 -0
  7. rowdelta-0.1.0/.gitignore +14 -0
  8. rowdelta-0.1.0/CHANGELOG.md +21 -0
  9. rowdelta-0.1.0/CONTRIBUTING.md +52 -0
  10. rowdelta-0.1.0/LICENSE +21 -0
  11. rowdelta-0.1.0/PKG-INFO +277 -0
  12. rowdelta-0.1.0/README.md +237 -0
  13. rowdelta-0.1.0/action.yml +113 -0
  14. rowdelta-0.1.0/benchmarks/bench.py +81 -0
  15. rowdelta-0.1.0/docs/terminal.svg +217 -0
  16. rowdelta-0.1.0/examples/customers_2026-10.csv +11 -0
  17. rowdelta-0.1.0/examples/customers_2026-11.csv +12 -0
  18. rowdelta-0.1.0/pyproject.toml +76 -0
  19. rowdelta-0.1.0/scripts/screenshots.py +37 -0
  20. rowdelta-0.1.0/src/rowdelta/__init__.py +20 -0
  21. rowdelta-0.1.0/src/rowdelta/__main__.py +5 -0
  22. rowdelta-0.1.0/src/rowdelta/cli.py +202 -0
  23. rowdelta-0.1.0/src/rowdelta/engine.py +619 -0
  24. rowdelta-0.1.0/src/rowdelta/model.py +157 -0
  25. rowdelta-0.1.0/src/rowdelta/py.typed +0 -0
  26. rowdelta-0.1.0/src/rowdelta/report/__init__.py +55 -0
  27. rowdelta-0.1.0/src/rowdelta/report/html.py +137 -0
  28. rowdelta-0.1.0/src/rowdelta/report/markdown.py +91 -0
  29. rowdelta-0.1.0/src/rowdelta/report/terminal.py +143 -0
  30. rowdelta-0.1.0/src/rowdelta/sources.py +161 -0
  31. rowdelta-0.1.0/tests/conftest.py +40 -0
  32. rowdelta-0.1.0/tests/test_engine.py +292 -0
  33. rowdelta-0.1.0/tests/test_property.py +84 -0
  34. rowdelta-0.1.0/tests/test_reports_cli.py +215 -0
  35. rowdelta-0.1.0/tests/test_sources.py +157 -0
@@ -0,0 +1,22 @@
1
+ name: Bug report
2
+ description: rowdelta gave a wrong answer, crashed, or showed a confusing message
3
+ labels: [bug]
4
+ body:
5
+ - type: textarea
6
+ id: what
7
+ attributes:
8
+ label: What happened
9
+ description: The command you ran and what you expected instead.
10
+ placeholder: rowdelta a.csv b.csv --key id
11
+ validations: { required: true }
12
+ - type: textarea
13
+ id: example
14
+ attributes:
15
+ label: A small example
16
+ description: Two tiny tables that show the problem (paste the CSV text). Please remove anything private.
17
+ - type: input
18
+ id: version
19
+ attributes:
20
+ label: Versions
21
+ description: Output of `rowdelta --version` and `python -c "import duckdb; print(duckdb.__version__)"`, and your OS.
22
+ validations: { required: true }
@@ -0,0 +1 @@
1
+ blank_issues_enabled: true
@@ -0,0 +1,15 @@
1
+ name: Feature request
2
+ description: Suggest a new source, option or report
3
+ labels: [enhancement]
4
+ body:
5
+ - type: textarea
6
+ id: need
7
+ attributes:
8
+ label: What are you trying to do?
9
+ description: The situation, and how rowdelta falls short today.
10
+ validations: { required: true }
11
+ - type: textarea
12
+ id: idea
13
+ attributes:
14
+ label: Your idea
15
+ description: The option, output or behaviour you would like.
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: /
5
+ schedule: { interval: monthly }
6
+ - package-ecosystem: pip
7
+ directory: /
8
+ schedule: { interval: monthly }
@@ -0,0 +1,87 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ lint:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with: { python-version: "3.13", cache: pip }
22
+ - run: pip install -e ".[dev]"
23
+ - run: ruff check .
24
+ - run: ruff format --check .
25
+ - run: mypy src
26
+
27
+ test:
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ os: [ubuntu-latest]
32
+ python: ["3.10", "3.11", "3.12", "3.13"]
33
+ include:
34
+ - { os: macos-latest, python: "3.13" }
35
+ - { os: windows-latest, python: "3.13" }
36
+ runs-on: ${{ matrix.os }}
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ - uses: actions/setup-python@v5
40
+ with: { python-version: "${{ matrix.python }}", cache: pip }
41
+ - run: pip install -e ".[dev]"
42
+ - run: pytest --cov --cov-report=term-missing
43
+ - name: Smoke-test the command
44
+ run: rowdelta examples/customers_2026-10.csv examples/customers_2026-11.csv --key customer_id --fail-on none
45
+
46
+ oldest-duckdb:
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ - uses: actions/setup-python@v5
51
+ with: { python-version: "3.10", cache: pip }
52
+ - run: pip install -e ".[dev]" "duckdb==1.1.*" "rich==13.7.*" "pandas<3"
53
+ - run: pytest
54
+
55
+ action:
56
+ # Runs the GitHub Action from this repository against the example data.
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+ with: { fetch-depth: 0 }
61
+ - id: diff
62
+ uses: ./
63
+ with:
64
+ before: examples/customers_2026-10.csv
65
+ after: examples/customers_2026-11.csv
66
+ key: customer_id
67
+ title: Example customer data
68
+ - name: Check the outputs
69
+ env:
70
+ HAS: ${{ steps.diff.outputs.has-differences }}
71
+ ADDED: ${{ steps.diff.outputs.added }}
72
+ REMOVED: ${{ steps.diff.outputs.removed }}
73
+ CHANGED: ${{ steps.diff.outputs.changed }}
74
+ REPORT: ${{ steps.diff.outputs.report }}
75
+ run: |
76
+ test "$HAS" = true
77
+ test "$ADDED" = 2 && test "$REMOVED" = 1 && test "$CHANGED" = 3
78
+ grep -q "Example customer data: differences found" "$REPORT"
79
+ - id: same
80
+ uses: ./
81
+ with:
82
+ before: HEAD:examples/customers_2026-10.csv
83
+ after: examples/customers_2026-10.csv
84
+ key: customer_id
85
+ fail-on: any
86
+ summary: "false"
87
+ - run: test "${{ steps.same.outputs.has-differences }}" = false
@@ -0,0 +1,44 @@
1
+ name: publish
2
+
3
+ # Publishes to PyPI with trusted publishing: no API token is stored anywhere.
4
+ # Runs when a GitHub release is published, or by hand from the Actions tab.
5
+ on:
6
+ release:
7
+ types: [published]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with: { python-version: "3.13" }
20
+ - run: python -m pip install --upgrade build twine
21
+ - run: python -m build
22
+ - run: twine check --strict dist/*
23
+ - name: Check the package version matches the release tag
24
+ if: github.event_name == 'release'
25
+ env:
26
+ TAG: ${{ github.event.release.tag_name }}
27
+ run: |
28
+ version=$(python -c "import re,pathlib; print(re.search(r'__version__ = \"(.+?)\"', pathlib.Path('src/rowdelta/__init__.py').read_text()).group(1))")
29
+ test "v$version" = "$TAG" || { echo "::error::tag $TAG does not match version $version"; exit 1; }
30
+ - uses: actions/upload-artifact@v4
31
+ with: { name: dist, path: dist/ }
32
+
33
+ pypi:
34
+ needs: build
35
+ runs-on: ubuntu-latest
36
+ environment:
37
+ name: pypi
38
+ url: https://pypi.org/p/rowdelta
39
+ permissions:
40
+ id-token: write
41
+ steps:
42
+ - uses: actions/download-artifact@v4
43
+ with: { name: dist, path: dist/ }
44
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+ .coverage
11
+ coverage.xml
12
+ htmlcov/
13
+ .hypothesis/
14
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 0.1.0 (2026-11-28)
6
+
7
+ First release.
8
+
9
+ - Keyed diff of two tables: added, removed, changed and unchanged rows, per-column change counts, and
10
+ example rows with before and after values.
11
+ - Sources: CSV/TSV (also gzip and zstd), Parquet files and globs, JSON and JSON Lines, SQLite and DuckDB
12
+ tables, files at a git revision (`REV:path`), and pandas, polars or Arrow data in Python.
13
+ - Composite keys; keys that are text on one side and numbers on the other.
14
+ - NULL-safe comparison, numeric tolerance (`--atol`, `--rtol`), `--trim`, `--ignore-case`, `--ignore`,
15
+ `--columns` and `--where`.
16
+ - Schema diff: added and removed columns and type changes (width-only changes are ignored).
17
+ - Duplicate and empty keys are counted, reported and left out rather than mismatched.
18
+ - Keyless multiset mode.
19
+ - Reports for the terminal, Markdown, JSON and HTML; `--export` of every changed row to Parquet, CSV or JSON.
20
+ - Exit codes and `--fail-on` for CI, and a composite GitHub Action.
21
+ - Key suggestions when no key is given.
@@ -0,0 +1,52 @@
1
+ # Contributing
2
+
3
+ Thanks for helping. Bug reports with a small example (two tiny CSVs and the command you ran) are the most
4
+ useful thing you can send.
5
+
6
+ ## Set up
7
+
8
+ ```bash
9
+ git clone https://github.com/Atharv1414/rowdelta && cd rowdelta
10
+ python -m venv .venv && source .venv/bin/activate
11
+ pip install -e ".[dev]"
12
+ ```
13
+
14
+ ## Checks
15
+
16
+ ```bash
17
+ ruff check . && ruff format --check .
18
+ mypy src
19
+ pytest --cov
20
+ ```
21
+
22
+ CI runs these on Linux (Python 3.10 to 3.13), macOS and Windows, and once more against the oldest
23
+ supported DuckDB (1.1). It also runs the GitHub Action against the example data.
24
+
25
+ ## Where things are
26
+
27
+ | Path | What |
28
+ |---|---|
29
+ | `src/rowdelta/engine.py` | The diff: SQL generation, matching, samples, export |
30
+ | `src/rowdelta/sources.py` | Reading files, database tables, git revisions and DataFrames |
31
+ | `src/rowdelta/model.py` | Result data classes and `to_dict()` |
32
+ | `src/rowdelta/report/` | Terminal, Markdown, HTML and JSON output |
33
+ | `src/rowdelta/cli.py` | The command line |
34
+ | `action.yml` | The GitHub Action |
35
+ | `tests/test_property.py` | Hypothesis tests against a plain-Python reference diff |
36
+
37
+ ## Guidelines
38
+
39
+ - Every behaviour change needs a test. If it touches matching or comparison, add a case to the property
40
+ tests too.
41
+ - Keep the heavy work in SQL. Python should only build queries and read small results.
42
+ - Quote identifiers with `q()` and string literals with `lit()` from `sources.py`; never paste user input
43
+ into SQL directly. (`--where` is the one deliberate exception: it is SQL by design.)
44
+ - Error messages should say what to do next, in plain words.
45
+ - Update `CHANGELOG.md` under "Unreleased".
46
+
47
+ ## Releasing
48
+
49
+ 1. Update the version in `src/rowdelta/__init__.py` and the changelog.
50
+ 2. Tag `vX.Y.Z` and move the `v0` tag (used by the GitHub Action) to the same commit.
51
+ 3. Create a GitHub release from the tag. The `publish` workflow then builds the package, checks that the
52
+ tag matches the version, and uploads it to PyPI through trusted publishing (no token is stored).
rowdelta-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atharv Patil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,277 @@
1
+ Metadata-Version: 2.5
2
+ Name: rowdelta
3
+ Version: 0.1.0
4
+ Summary: Diff two tables (CSV, Parquet, JSON, SQLite, DuckDB or git revisions) by key: added, removed and changed rows, column by column. Fast, because it runs on DuckDB.
5
+ Project-URL: Homepage, https://github.com/Atharv1414/rowdelta
6
+ Project-URL: Issues, https://github.com/Atharv1414/rowdelta/issues
7
+ Project-URL: Changelog, https://github.com/Atharv1414/rowdelta/blob/main/CHANGELOG.md
8
+ Author: Atharv Patil
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,csv,data-diff,data-engineering,data-quality,diff,duckdb,github-action,parquet,testing
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Software Development :: Testing
24
+ Classifier: Topic :: Utilities
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: duckdb>=1.1
28
+ Requires-Dist: rich>=13.7
29
+ Provides-Extra: dev
30
+ Requires-Dist: hypothesis>=6.100; extra == 'dev'
31
+ Requires-Dist: mypy>=1.10; extra == 'dev'
32
+ Requires-Dist: pandas>=2.0; extra == 'dev'
33
+ Requires-Dist: polars>=1.0; extra == 'dev'
34
+ Requires-Dist: pyarrow>=15; extra == 'dev'
35
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
36
+ Requires-Dist: pytest>=8; extra == 'dev'
37
+ Requires-Dist: ruff>=0.6; extra == 'dev'
38
+ Requires-Dist: zstandard>=0.22; extra == 'dev'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # rowdelta
42
+
43
+ **See exactly what changed between two versions of a table.**
44
+
45
+ rowdelta matches rows by key and tells you which rows were added, removed and changed, and which columns
46
+ changed in each one. It reads CSV, Parquet, JSON, SQLite, DuckDB, pandas and Arrow, or a file at a git
47
+ revision, and it runs on [DuckDB](https://duckdb.org), so ten million rows take seconds.
48
+
49
+ [![ci](https://github.com/Atharv1414/rowdelta/actions/workflows/ci.yml/badge.svg)](https://github.com/Atharv1414/rowdelta/actions/workflows/ci.yml)
50
+ ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-3776AB?logo=python&logoColor=white)
51
+ ![DuckDB](https://img.shields.io/badge/engine-DuckDB-FFF000?logo=duckdb&logoColor=black)
52
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/Atharv1414/rowdelta/blob/main/LICENSE)
53
+
54
+ ![rowdelta comparing two customer exports: 2 added, 1 removed and 3 changed rows, a new column, and the before and after values](https://raw.githubusercontent.com/Atharv1414/rowdelta/main/docs/terminal.svg)
55
+
56
+ ```bash
57
+ rowdelta customers_2026-10.csv customers_2026-11.csv --key customer_id
58
+ ```
59
+
60
+ ## Why
61
+
62
+ Tables change all the time: a nightly export, a dbt model after a refactor, a pipeline after an upgrade,
63
+ a spreadsheet someone "fixed". `git diff` on a CSV compares lines, not records, so it falls apart as soon
64
+ as rows are reordered, a column moves, or `29` becomes `29.0`. Most teams end up writing the same
65
+ one-off pandas script each time.
66
+
67
+ rowdelta is that script done properly, once:
68
+
69
+ - **Matches rows by key**, including composite keys, so order never matters.
70
+ - **Shows the change itself**: for each changed row, which columns changed and their old and new values.
71
+ - **Is safe with real data**: NULLs compare correctly, duplicate and empty keys are reported instead of
72
+ silently mismatched, and columns match even when their order or capitalisation differs.
73
+ - **Fits into CI**: exit code `1` when something differs, Markdown output for pull request comments,
74
+ JSON for scripts, and a ready-made GitHub Action.
75
+ - **Is fast**: one DuckDB join does the work. See [Performance](#performance).
76
+
77
+ ## Install
78
+
79
+ ```bash
80
+ pipx install git+https://github.com/Atharv1414/rowdelta
81
+ ```
82
+
83
+ or `pip install git+https://github.com/Atharv1414/rowdelta`. It needs Python 3.10 or newer and installs
84
+ two dependencies: `duckdb` and `rich`.
85
+
86
+ ## Quick start
87
+
88
+ ```bash
89
+ # Two files, matched on a key
90
+ rowdelta before.csv after.csv --key id
91
+
92
+ # Any mix of formats, and composite keys
93
+ rowdelta orders_old.parquet orders.csv --key order_id,line_no
94
+
95
+ # What changed in a file since the last commit, or against main
96
+ rowdelta HEAD:data/prices.csv data/prices.csv --key sku
97
+ rowdelta origin/main:data/prices.csv data/prices.csv --key sku
98
+
99
+ # A table in SQLite or DuckDB
100
+ rowdelta prod.sqlite::users staging.sqlite::users --key id
101
+
102
+ # Ignore noise: timestamps, tiny float differences, case and spaces
103
+ rowdelta a.parquet b.parquet --key id --ignore updated_at --atol 0.005 --trim --ignore-case
104
+
105
+ # Only some rows, only some columns
106
+ rowdelta a.csv b.csv --key id --where "country = 'GB'" --columns price,stock
107
+
108
+ # Reports and the full list of changes
109
+ rowdelta a.csv b.csv --key id -o report.html -o report.json
110
+ rowdelta a.csv b.csv --key id --export changes.parquet
111
+ ```
112
+
113
+ `--export` writes every added, removed and changed row with a `status` column, a `changed_columns` column,
114
+ and `<column>_before` / `<column>_after` pairs, so you can keep investigating in SQL, pandas or a
115
+ spreadsheet.
116
+
117
+ No key? rowdelta suggests columns that look like one. Or use `--keyless` to compare whole rows as a
118
+ multiset (it then reports added and removed copies, but cannot say which rows "changed").
119
+
120
+ ## Sources
121
+
122
+ | Source | Example |
123
+ |---|---|
124
+ | CSV, TSV (also `.gz`, `.zst`) | `data.csv`, `data.tsv.gz` |
125
+ | Parquet, one file or a glob | `data.parquet`, `"lake/2026/*.parquet"` |
126
+ | JSON array or JSON Lines | `data.json`, `data.jsonl` |
127
+ | SQLite table | `app.sqlite::users` (`.sqlite`, `.sqlite3`, `.db`) |
128
+ | DuckDB table | `warehouse.duckdb::orders` |
129
+ | A file at a git revision | `main:data/users.csv`, `HEAD~3:data/users.csv` |
130
+ | pandas, polars, Arrow (Python API) | `rowdelta.compare(df_old, df_new, key="id")` |
131
+
132
+ The two sides can be different formats. A column that is text on one side and numeric on the other is
133
+ compared as text (so `01234` vs `1234` is a change); integers and floats are compared as numbers.
134
+ Differences only in width, such as `INTEGER` vs `BIGINT`, are not reported as schema changes.
135
+
136
+ ## In CI: the GitHub Action
137
+
138
+ Post a diff on every pull request that changes a data file:
139
+
140
+ ```yaml
141
+ name: data diff
142
+ on:
143
+ pull_request:
144
+ paths: ["data/**"]
145
+
146
+ jobs:
147
+ diff:
148
+ runs-on: ubuntu-latest
149
+ permissions:
150
+ contents: read
151
+ pull-requests: write
152
+ steps:
153
+ - uses: actions/checkout@v4
154
+ with:
155
+ fetch-depth: 0 # so the base branch is available to compare against
156
+
157
+ - id: diff
158
+ uses: Atharv1414/rowdelta@v0
159
+ with:
160
+ before: origin/${{ github.base_ref }}:data/customers.csv
161
+ after: data/customers.csv
162
+ key: customer_id
163
+ args: --ignore updated_at
164
+ # fail-on: removed # make the check fail if any rows were removed
165
+
166
+ - uses: marocchino/sticky-pull-request-comment@v2
167
+ with:
168
+ path: ${{ steps.diff.outputs.report }}
169
+ ```
170
+
171
+ The report also goes to the job summary. Outputs: `has-differences`, `added`, `removed`, `changed`,
172
+ `report` (Markdown file) and `json` (JSON file). Set `fail-on` to `any`, `rows`, `schema`, `added`,
173
+ `removed` or `changed` to turn the step into a gate; it defaults to `none`, which only reports.
174
+
175
+ Without the Action, any CI system can use the exit code:
176
+
177
+ ```bash
178
+ rowdelta expected.parquet actual.parquet --key id --quiet # 0 = same, 1 = different, 2 = error
179
+ ```
180
+
181
+ ## Python API
182
+
183
+ ```python
184
+ import rowdelta
185
+
186
+ with rowdelta.compare("old.parquet", "new.parquet", key=["order_id", "line"], atol=0.01) as diff:
187
+ print(diff.added, diff.removed, diff.changed, diff.unchanged)
188
+ print(diff.column_changes) # {'price': 812, 'status': 40}
189
+ print(diff.schema.only_in_b) # new columns
190
+ for row in diff.rows("changed", limit=5):
191
+ print(row) # {'status': 'changed', 'order_id': 7, 'price_before': 9.5, ...}
192
+ diff.export("changes.parquet")
193
+
194
+ report = diff.result.to_dict() # plain data, safe to keep after the connection closes
195
+ ```
196
+
197
+ `compare` also accepts pandas or polars DataFrames and Arrow tables. Useful in tests:
198
+
199
+ ```python
200
+ def test_refactor_keeps_output_identical(old_model, new_model):
201
+ with rowdelta.compare(old_model, new_model, key="id", atol=1e-9) as diff:
202
+ assert not diff.has_differences, diff.column_changes
203
+ ```
204
+
205
+ ## Options
206
+
207
+ | Option | What it does |
208
+ |---|---|
209
+ | `-k, --key COL` | Column(s) that identify a row. Repeat or comma-separate for a composite key. |
210
+ | `--keyless` | Compare whole rows as a multiset instead of by key. |
211
+ | `-c, --columns COL` | Compare only these columns. |
212
+ | `-i, --ignore COL` | Leave these columns out. |
213
+ | `--atol N`, `--rtol N` | Numbers within `atol + rtol × abs(after)` count as equal. |
214
+ | `--trim`, `--ignore-case` | Ignore spaces at the ends of text, or differences in case. |
215
+ | `--where SQL` | Filter both sides first, e.g. `"region = 'EU'"`. |
216
+ | `-o, --output FILE` | Write a report: `.md`, `.json`, `.html`, anything else is text. Repeatable. |
217
+ | `-f, --format` | `terminal`, `markdown`, `json` or `html` for the screen (or a single `-o`). |
218
+ | `--export FILE` | Every changed row with before and after values, as `.parquet`, `.csv` or `.json`. |
219
+ | `-n, --sample N` | Example rows per kind in reports (default 10). |
220
+ | `--fail-on WHAT` | What sets exit code 1: `any` (default), `rows`, `schema`, `added`, `removed`, `changed`, `none`. |
221
+ | `--labels A B` | Names to show instead of the paths. |
222
+ | `--title TEXT` | Heading for Markdown and HTML reports. |
223
+ | `--memory-limit 2GB` | Cap DuckDB's memory; larger work spills to disk. |
224
+ | `-q, --quiet` | Print nothing; files are still written. |
225
+
226
+ ## Performance
227
+
228
+ Measured with [`benchmarks/bench.py`](https://github.com/Atharv1414/rowdelta/blob/main/benchmarks/bench.py) on a MacBook Air (Apple M2, 8 GB RAM), DuckDB
229
+ 2.0.1, Python 3.13. Table B is table A with 1% of rows changed, 0.5% removed and 0.5% added; 8 columns of
230
+ mixed types. Times include reading both files and computing counts, per-column totals and samples.
231
+
232
+ | Rows | Format | Added | Removed | Changed | Time |
233
+ |---:|---|---:|---:|---:|---:|
234
+ | 1,000,000 | Parquet | 5,000 | 5,000 | 10,000 | 0.3 s |
235
+ | 1,000,000 | CSV | 5,000 | 5,000 | 10,000 | 0.6 s |
236
+ | 10,000,000 | Parquet | 50,000 | 50,000 | 100,000 | 7.3 s |
237
+
238
+ Run `python benchmarks/bench.py` to measure on your machine.
239
+
240
+ ## How it works
241
+
242
+ 1. Each side is loaded into DuckDB (filtered by `--where`), and the two schemas are compared.
243
+ 2. Rows with an empty key, and keys that appear more than once on either side, are counted and set aside,
244
+ because they cannot be matched one to one. They are reported, never guessed.
245
+ 3. A single `FULL OUTER JOIN` on the key gives each key a status (added, removed, changed or same), with
246
+ one NULL-safe "differs" flag per compared column that applies the tolerance and text options.
247
+ 4. Totals and per-column counts come from that one table; samples and `--export` join back for values.
248
+
249
+ The engine is about 600 lines in [`src/rowdelta/engine.py`](https://github.com/Atharv1414/rowdelta/blob/main/src/rowdelta/engine.py). Tests compare it
250
+ against a plain-Python reference diff on hundreds of random tables on every run, using
251
+ [Hypothesis](https://hypothesis.readthedocs.io).
252
+
253
+ ## Limits
254
+
255
+ - Both tables are loaded into DuckDB. Large inputs spill to disk, but very large ones are better compared
256
+ where they live; set `--memory-limit` to keep a laptop responsive.
257
+ - Comparing tables directly inside Postgres, MySQL or a cloud warehouse is not built in yet. Export to
258
+ Parquet first (or use DuckDB's database extensions with the Python API).
259
+ - Excel files are not read directly; save as CSV.
260
+ - Floats compare exactly unless you give `--atol` or `--rtol`.
261
+ - Not on PyPI yet; install from GitHub as shown above.
262
+
263
+ ## Related tools
264
+
265
+ [datacompy](https://github.com/capitalone/datacompy) is a Python library for comparing DataFrames.
266
+ Datafold's [data-diff](https://github.com/datafold/data-diff), which compared tables across databases, was
267
+ archived in May 2024. rowdelta aims at the everyday case: two files or tables, one command, a clear answer,
268
+ and a report you can paste into a pull request.
269
+
270
+ ## Contributing
271
+
272
+ Issues and pull requests are welcome; see [CONTRIBUTING.md](https://github.com/Atharv1414/rowdelta/blob/main/CONTRIBUTING.md). Good first areas: more
273
+ sources (Excel, Postgres through DuckDB extensions), report polish, and Windows testing.
274
+
275
+ ## License
276
+
277
+ MIT