rowproof 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.
- rowproof-0.1.0/LICENSE +201 -0
- rowproof-0.1.0/PKG-INFO +172 -0
- rowproof-0.1.0/README.md +150 -0
- rowproof-0.1.0/pyproject.toml +44 -0
- rowproof-0.1.0/rowproof/__init__.py +1 -0
- rowproof-0.1.0/rowproof/cli/__init__.py +0 -0
- rowproof-0.1.0/rowproof/cli/main.py +548 -0
- rowproof-0.1.0/rowproof/cli/render.py +132 -0
- rowproof-0.1.0/rowproof/cli/spec.py +99 -0
- rowproof-0.1.0/rowproof/config/__init__.py +167 -0
- rowproof-0.1.0/rowproof/connectors/__init__.py +0 -0
- rowproof-0.1.0/rowproof/connectors/_chwire.py +160 -0
- rowproof-0.1.0/rowproof/connectors/_pgwire.py +165 -0
- rowproof-0.1.0/rowproof/connectors/_sfwire.py +157 -0
- rowproof-0.1.0/rowproof/connectors/base.py +120 -0
- rowproof-0.1.0/rowproof/connectors/clickhouse.py +580 -0
- rowproof-0.1.0/rowproof/connectors/postgres.py +470 -0
- rowproof-0.1.0/rowproof/connectors/snowflake.py +477 -0
- rowproof-0.1.0/rowproof/core/__init__.py +0 -0
- rowproof-0.1.0/rowproof/core/column_matching.py +217 -0
- rowproof-0.1.0/rowproof/core/errors.py +37 -0
- rowproof-0.1.0/rowproof/core/hashdiff.py +933 -0
- rowproof-0.1.0/rowproof/core/joindiff.py +304 -0
- rowproof-0.1.0/rowproof/core/models.py +192 -0
- rowproof-0.1.0/rowproof/core/normalisation.py +119 -0
- rowproof-0.1.0/rowproof/core/segmentation.py +159 -0
- rowproof-0.1.0/rowproof/report/__init__.py +6 -0
- rowproof-0.1.0/rowproof/report/html.py +167 -0
- rowproof-0.1.0/rowproof.egg-info/PKG-INFO +172 -0
- rowproof-0.1.0/rowproof.egg-info/SOURCES.txt +33 -0
- rowproof-0.1.0/rowproof.egg-info/dependency_links.txt +1 -0
- rowproof-0.1.0/rowproof.egg-info/entry_points.txt +2 -0
- rowproof-0.1.0/rowproof.egg-info/requires.txt +14 -0
- rowproof-0.1.0/rowproof.egg-info/top_level.txt +1 -0
- rowproof-0.1.0/setup.cfg +4 -0
rowproof-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the
|
|
44
|
+
purposes of this License, Derivative Works shall not include works
|
|
45
|
+
that remain separable from, or merely link (or bind by name) to the
|
|
46
|
+
interfaces of, the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including the
|
|
49
|
+
original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing
|
|
141
|
+
the origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 the rowproof authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
rowproof-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rowproof
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Prove a database migration or replication didn't lose, add or change a single row.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: pyyaml>=6.0
|
|
10
|
+
Requires-Dist: jinja2>=3.1
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
12
|
+
Requires-Dist: rich>=13
|
|
13
|
+
Requires-Dist: psycopg[binary]>=3.1
|
|
14
|
+
Requires-Dist: clickhouse-connect>=0.7
|
|
15
|
+
Provides-Extra: snowflake
|
|
16
|
+
Requires-Dist: snowflake-connector-python>=3.6; extra == "snowflake"
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
20
|
+
Requires-Dist: testcontainers>=4.0; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# rowproof
|
|
24
|
+
|
|
25
|
+
**rowproof proves that a database migration or replication didn't lose, add or change a single row — and gives you a report you can sign off on.**
|
|
26
|
+
|
|
27
|
+
Diffing is the plumbing. The product is the proof: exact counts, every difference explained with a rule citation, reproducible SQL, and a self-contained HTML sign-off report.
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
_60-second terminal demo GIF: recording script is in [docs/demo.tape](docs/demo.tape) (`vhs docs/demo.tape`, needs `ttyd`+`ffmpeg`) — not yet rendered in this environment; see the CLI output further down for what it shows._
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pipx install rowproof
|
|
37
|
+
pipx install "rowproof[snowflake]" # adds Snowflake support
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
(`pip install rowproof` / `pip install "rowproof[snowflake]"` work too — `pipx` just keeps the CLI's dependencies out of your other Python environments.)
|
|
41
|
+
|
|
42
|
+
## 60-second demo
|
|
43
|
+
|
|
44
|
+
Using the Postgres and ClickHouse containers from this repo's `docker-compose.yml`:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
docker compose up -d
|
|
48
|
+
rowproof diff postgres://postgres:postgres@localhost:5432/postgres/public.orders \
|
|
49
|
+
clickhouse://default:clickhouse@localhost:8123/default/orders \
|
|
50
|
+
--key id --output html --html-path report.html
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Two commands. Open `report.html` and you have a sign-off document — exact row counts on both sides, every difference cited against a published rule, and the SQL to reproduce each one.
|
|
54
|
+
|
|
55
|
+
Run it with the default terminal output instead (no `--output`/`--html-path`) and here's what a real run looks like — this table pair has one row deliberately changed and one deliberately deleted on the ClickHouse side, and rowproof catches both:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
$ rowproof diff postgres://postgres:postgres@127.0.0.1:5432/postgres/public.orders \
|
|
59
|
+
clickhouse://default:clickhouse@127.0.0.1:8123/default/orders --key id
|
|
60
|
+
public.orders postgres:postgres/public.orders -> clickhouse:default/orders
|
|
61
|
+
rows 5000 4999
|
|
62
|
+
key id
|
|
63
|
+
algorithm hashdiff · 8 segments · 10 queries/side · 0.2s
|
|
64
|
+
|
|
65
|
+
missing in target 1
|
|
66
|
+
extra in target 0
|
|
67
|
+
changed 1
|
|
68
|
+
|
|
69
|
+
key=42 customer 'customer-42' -> 'customer-999' (STR-1)
|
|
70
|
+
key=4500 missing
|
|
71
|
+
warning: row counts differ: source=5000 target=4999
|
|
72
|
+
|
|
73
|
+
result DIFFERENT exit 1
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## What it checks — and what it never does
|
|
77
|
+
|
|
78
|
+
- Verifies every row matches: counts, missing rows, extra rows, and changed values, down to the specific column and the exact rule that governed the comparison (a timestamp precision mismatch and a NULL-vs-empty-string mismatch are not the same bug, and rowproof tells you which one you have).
|
|
79
|
+
- **Never writes to your database.** Every connector is read-only by construction — `SELECT` and schema-introspection queries only, nothing else. It works with a read-only database role.
|
|
80
|
+
- **Zero telemetry.** Nothing phones home. Read the source; there's no network call in this codebase that isn't the one you told it to make.
|
|
81
|
+
|
|
82
|
+
## Supported engines
|
|
83
|
+
|
|
84
|
+
| Engine | Driver | Notes |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| Postgres | `psycopg` (v3) | |
|
|
87
|
+
| ClickHouse | `clickhouse-connect` | |
|
|
88
|
+
| Snowflake | `snowflake-connector-python` | Optional extra: `rowproof[snowflake]` |
|
|
89
|
+
|
|
90
|
+
## Supported types (canonical comparison rules)
|
|
91
|
+
|
|
92
|
+
Every cross-engine type difference is governed by one of these published rules, and every difference rowproof reports cites the rule ID that applied — never a vague "values differ."
|
|
93
|
+
|
|
94
|
+
| Rule | Applies to | Canonical form | Notes |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| NULL-1 | any nullable | the literal `\N` | Distinct from empty string. `NULL` ≠ `''` always. |
|
|
97
|
+
| INT-1 | integers | decimal digits, no leading zeros, `-` sign | |
|
|
98
|
+
| DEC-1 | fixed-point decimal | digits at the pair's minimum scale, round half-even | Reported when scales differ |
|
|
99
|
+
| FLT-1 | float / double | scientific notation, 15 significant digits by default | `--float-precision N` overrides |
|
|
100
|
+
| STR-1 | text | as-is, UTF-8 | No trimming, no case folding by default |
|
|
101
|
+
| STR-2 | text, opt-in | `--trim` / `--case-insensitive` | Cited in output when active |
|
|
102
|
+
| BOOL-1 | boolean | `true` / `false` | Handles integer 0/1 vs boolean across engines |
|
|
103
|
+
| TS-1 | timestamp with tz | ISO 8601 UTC, `YYYY-MM-DDTHH:MM:SS.ffffffZ` | Always 6 fractional digits |
|
|
104
|
+
| TS-2 | timestamp precision differs | rounded to the pair's lower precision | e.g. Postgres µs vs ClickHouse `DateTime` (seconds) |
|
|
105
|
+
| TS-3 | timestamp without tz | rendered as-is with `Z`, assumed UTC, warns once | `--assume-tz` overrides |
|
|
106
|
+
| DATE-1 | date | `YYYY-MM-DD` | |
|
|
107
|
+
| TIME-1 | time | `HH:MM:SS.ffffff` | |
|
|
108
|
+
| UUID-1 | uuid | lower-case, hyphenated | Handles a uuid stored as VARCHAR (Snowflake) |
|
|
109
|
+
| BIN-1 | bytea / binary | lower-case hex | |
|
|
110
|
+
| JSON-1 | json / jsonb | text after engine-side canonicalisation if available | Full key-order-independent compare is a future release |
|
|
111
|
+
| ARR-1 | arrays | `[` + elements joined by `,` + `]` | Order-sensitive |
|
|
112
|
+
| ENUM-1 | enums | the label as text | |
|
|
113
|
+
| UNK-1 | anything unmapped | cast to text, warns once, cites the rule | Never fails a run over an unknown type |
|
|
114
|
+
|
|
115
|
+
## How it works
|
|
116
|
+
|
|
117
|
+
1. Get `MIN(pk)`, `MAX(pk)`, `COUNT(*)` on both sides.
|
|
118
|
+
2. Split the key range into segments (~100k rows each).
|
|
119
|
+
3. Hash each segment's normalised rows into one aggregate per side, in one query — the databases do the work, not the client.
|
|
120
|
+
4. Compare hashes. Matching segments are done; mismatched ones bisect recursively until small.
|
|
121
|
+
5. For small mismatched segments, fetch normalised rows from both sides and diff them in the client.
|
|
122
|
+
6. Cap the collected row-level differences (`--max-diff-rows`); counts stay exact regardless.
|
|
123
|
+
7. When both tables live in the same connection, skip all of the above — one `FULL OUTER JOIN` does it exactly, in one query.
|
|
124
|
+
8. Client memory never holds more than one segment's worth of rows at a time — a 100-million-row table and a 100-row table cost the client about the same.
|
|
125
|
+
|
|
126
|
+
## `rowproof explain` — proof of transparency
|
|
127
|
+
|
|
128
|
+
`explain` prints the exact SQL a `diff` would run, without ever executing it against your data:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
$ rowproof explain postgres://postgres:postgres@127.0.0.1:5432/postgres/public.orders \
|
|
132
|
+
clickhouse://default:clickhouse@127.0.0.1:8123/default/orders --key id
|
|
133
|
+
-- source: row-count and bounds
|
|
134
|
+
SELECT MIN("id"), MAX("id"), COUNT(*) FROM "public"."orders"
|
|
135
|
+
-- target: row-count and bounds
|
|
136
|
+
SELECT MIN(`id`), MAX(`id`), COUNT(*) FROM `orders`
|
|
137
|
+
-- source: uniqueness check on the key
|
|
138
|
+
SELECT "id", COUNT(*) FROM "public"."orders" GROUP BY "id" HAVING COUNT(*) > 1 LIMIT 1
|
|
139
|
+
-- target: uniqueness check on the key
|
|
140
|
+
SELECT `id`, COUNT(*) FROM `orders` GROUP BY `id` HAVING COUNT(*) > 1 LIMIT 1
|
|
141
|
+
-- source: per-segment count + hash (one per segment)
|
|
142
|
+
SELECT COUNT(*), ((sum(((('x' || substr(md5(("id"::text) || E'\x1f' || ...
|
|
143
|
+
-- target: per-segment count + hash (one per segment)
|
|
144
|
+
SELECT COUNT(*), ((sum(toInt256(reinterpretAsInt64(reverse(unhex(substr(lower(hex(MD5(...
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Every line above is real output from an actual Postgres/ClickHouse pair — copied verbatim, not hand-written. The hash expressions get long fast (each engine's DEC-1/TS-1 rendering is spelled out in full, no black box); the complete, unedited transcript for this exact table pair is in [docs/explain-output.txt](docs/explain-output.txt).
|
|
148
|
+
|
|
149
|
+
## Exit codes (for CI)
|
|
150
|
+
|
|
151
|
+
| Code | Meaning |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `0` | Tables match |
|
|
154
|
+
| `1` | Differences found |
|
|
155
|
+
| `2` | Could not compare (schema incompatible, missing key, connection failure) |
|
|
156
|
+
|
|
157
|
+
## How is this different from reladiff / data-diff?
|
|
158
|
+
|
|
159
|
+
[reladiff](https://github.com/erezsh/reladiff) is an excellent, actively maintained diffing library, and rowproof uses the same hash-and-bisect idea it and its predecessor `data-diff` popularized. rowproof differs in three ways: every cross-engine type difference is governed by a published rule table and cited in the output; the output is a sign-off report meant to be attached to a cutover approval, not just a diff count; and the CLI is the free core of a hosted reconciliation service (scheduled runs, history, alerts) rather than a standalone library.
|
|
160
|
+
|
|
161
|
+
## Benchmark
|
|
162
|
+
|
|
163
|
+
100M rows, verified correct (exactly the 1,000 differences introduced, nothing else), 127 MB peak client memory, 8.95 minutes on a laptop with both databases sharing the same 8 vCPUs. Full methodology and hardware details in [docs/benchmarks.md](docs/benchmarks.md).
|
|
164
|
+
|
|
165
|
+
## Roadmap
|
|
166
|
+
|
|
167
|
+
- More engines: Databricks, BigQuery, Iceberg, MySQL
|
|
168
|
+
- A hosted reconciliation service: scheduled runs, run history, Slack/email alerts, sign-off reports for a whole migration. Waitlist link coming soon.
|
|
169
|
+
|
|
170
|
+
## Licence
|
|
171
|
+
|
|
172
|
+
Apache 2.0.
|
rowproof-0.1.0/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# rowproof
|
|
2
|
+
|
|
3
|
+
**rowproof proves that a database migration or replication didn't lose, add or change a single row — and gives you a report you can sign off on.**
|
|
4
|
+
|
|
5
|
+
Diffing is the plumbing. The product is the proof: exact counts, every difference explained with a rule citation, reproducible SQL, and a self-contained HTML sign-off report.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
_60-second terminal demo GIF: recording script is in [docs/demo.tape](docs/demo.tape) (`vhs docs/demo.tape`, needs `ttyd`+`ffmpeg`) — not yet rendered in this environment; see the CLI output further down for what it shows._
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pipx install rowproof
|
|
15
|
+
pipx install "rowproof[snowflake]" # adds Snowflake support
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
(`pip install rowproof` / `pip install "rowproof[snowflake]"` work too — `pipx` just keeps the CLI's dependencies out of your other Python environments.)
|
|
19
|
+
|
|
20
|
+
## 60-second demo
|
|
21
|
+
|
|
22
|
+
Using the Postgres and ClickHouse containers from this repo's `docker-compose.yml`:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
docker compose up -d
|
|
26
|
+
rowproof diff postgres://postgres:postgres@localhost:5432/postgres/public.orders \
|
|
27
|
+
clickhouse://default:clickhouse@localhost:8123/default/orders \
|
|
28
|
+
--key id --output html --html-path report.html
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Two commands. Open `report.html` and you have a sign-off document — exact row counts on both sides, every difference cited against a published rule, and the SQL to reproduce each one.
|
|
32
|
+
|
|
33
|
+
Run it with the default terminal output instead (no `--output`/`--html-path`) and here's what a real run looks like — this table pair has one row deliberately changed and one deliberately deleted on the ClickHouse side, and rowproof catches both:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
$ rowproof diff postgres://postgres:postgres@127.0.0.1:5432/postgres/public.orders \
|
|
37
|
+
clickhouse://default:clickhouse@127.0.0.1:8123/default/orders --key id
|
|
38
|
+
public.orders postgres:postgres/public.orders -> clickhouse:default/orders
|
|
39
|
+
rows 5000 4999
|
|
40
|
+
key id
|
|
41
|
+
algorithm hashdiff · 8 segments · 10 queries/side · 0.2s
|
|
42
|
+
|
|
43
|
+
missing in target 1
|
|
44
|
+
extra in target 0
|
|
45
|
+
changed 1
|
|
46
|
+
|
|
47
|
+
key=42 customer 'customer-42' -> 'customer-999' (STR-1)
|
|
48
|
+
key=4500 missing
|
|
49
|
+
warning: row counts differ: source=5000 target=4999
|
|
50
|
+
|
|
51
|
+
result DIFFERENT exit 1
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## What it checks — and what it never does
|
|
55
|
+
|
|
56
|
+
- Verifies every row matches: counts, missing rows, extra rows, and changed values, down to the specific column and the exact rule that governed the comparison (a timestamp precision mismatch and a NULL-vs-empty-string mismatch are not the same bug, and rowproof tells you which one you have).
|
|
57
|
+
- **Never writes to your database.** Every connector is read-only by construction — `SELECT` and schema-introspection queries only, nothing else. It works with a read-only database role.
|
|
58
|
+
- **Zero telemetry.** Nothing phones home. Read the source; there's no network call in this codebase that isn't the one you told it to make.
|
|
59
|
+
|
|
60
|
+
## Supported engines
|
|
61
|
+
|
|
62
|
+
| Engine | Driver | Notes |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| Postgres | `psycopg` (v3) | |
|
|
65
|
+
| ClickHouse | `clickhouse-connect` | |
|
|
66
|
+
| Snowflake | `snowflake-connector-python` | Optional extra: `rowproof[snowflake]` |
|
|
67
|
+
|
|
68
|
+
## Supported types (canonical comparison rules)
|
|
69
|
+
|
|
70
|
+
Every cross-engine type difference is governed by one of these published rules, and every difference rowproof reports cites the rule ID that applied — never a vague "values differ."
|
|
71
|
+
|
|
72
|
+
| Rule | Applies to | Canonical form | Notes |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| NULL-1 | any nullable | the literal `\N` | Distinct from empty string. `NULL` ≠ `''` always. |
|
|
75
|
+
| INT-1 | integers | decimal digits, no leading zeros, `-` sign | |
|
|
76
|
+
| DEC-1 | fixed-point decimal | digits at the pair's minimum scale, round half-even | Reported when scales differ |
|
|
77
|
+
| FLT-1 | float / double | scientific notation, 15 significant digits by default | `--float-precision N` overrides |
|
|
78
|
+
| STR-1 | text | as-is, UTF-8 | No trimming, no case folding by default |
|
|
79
|
+
| STR-2 | text, opt-in | `--trim` / `--case-insensitive` | Cited in output when active |
|
|
80
|
+
| BOOL-1 | boolean | `true` / `false` | Handles integer 0/1 vs boolean across engines |
|
|
81
|
+
| TS-1 | timestamp with tz | ISO 8601 UTC, `YYYY-MM-DDTHH:MM:SS.ffffffZ` | Always 6 fractional digits |
|
|
82
|
+
| TS-2 | timestamp precision differs | rounded to the pair's lower precision | e.g. Postgres µs vs ClickHouse `DateTime` (seconds) |
|
|
83
|
+
| TS-3 | timestamp without tz | rendered as-is with `Z`, assumed UTC, warns once | `--assume-tz` overrides |
|
|
84
|
+
| DATE-1 | date | `YYYY-MM-DD` | |
|
|
85
|
+
| TIME-1 | time | `HH:MM:SS.ffffff` | |
|
|
86
|
+
| UUID-1 | uuid | lower-case, hyphenated | Handles a uuid stored as VARCHAR (Snowflake) |
|
|
87
|
+
| BIN-1 | bytea / binary | lower-case hex | |
|
|
88
|
+
| JSON-1 | json / jsonb | text after engine-side canonicalisation if available | Full key-order-independent compare is a future release |
|
|
89
|
+
| ARR-1 | arrays | `[` + elements joined by `,` + `]` | Order-sensitive |
|
|
90
|
+
| ENUM-1 | enums | the label as text | |
|
|
91
|
+
| UNK-1 | anything unmapped | cast to text, warns once, cites the rule | Never fails a run over an unknown type |
|
|
92
|
+
|
|
93
|
+
## How it works
|
|
94
|
+
|
|
95
|
+
1. Get `MIN(pk)`, `MAX(pk)`, `COUNT(*)` on both sides.
|
|
96
|
+
2. Split the key range into segments (~100k rows each).
|
|
97
|
+
3. Hash each segment's normalised rows into one aggregate per side, in one query — the databases do the work, not the client.
|
|
98
|
+
4. Compare hashes. Matching segments are done; mismatched ones bisect recursively until small.
|
|
99
|
+
5. For small mismatched segments, fetch normalised rows from both sides and diff them in the client.
|
|
100
|
+
6. Cap the collected row-level differences (`--max-diff-rows`); counts stay exact regardless.
|
|
101
|
+
7. When both tables live in the same connection, skip all of the above — one `FULL OUTER JOIN` does it exactly, in one query.
|
|
102
|
+
8. Client memory never holds more than one segment's worth of rows at a time — a 100-million-row table and a 100-row table cost the client about the same.
|
|
103
|
+
|
|
104
|
+
## `rowproof explain` — proof of transparency
|
|
105
|
+
|
|
106
|
+
`explain` prints the exact SQL a `diff` would run, without ever executing it against your data:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
$ rowproof explain postgres://postgres:postgres@127.0.0.1:5432/postgres/public.orders \
|
|
110
|
+
clickhouse://default:clickhouse@127.0.0.1:8123/default/orders --key id
|
|
111
|
+
-- source: row-count and bounds
|
|
112
|
+
SELECT MIN("id"), MAX("id"), COUNT(*) FROM "public"."orders"
|
|
113
|
+
-- target: row-count and bounds
|
|
114
|
+
SELECT MIN(`id`), MAX(`id`), COUNT(*) FROM `orders`
|
|
115
|
+
-- source: uniqueness check on the key
|
|
116
|
+
SELECT "id", COUNT(*) FROM "public"."orders" GROUP BY "id" HAVING COUNT(*) > 1 LIMIT 1
|
|
117
|
+
-- target: uniqueness check on the key
|
|
118
|
+
SELECT `id`, COUNT(*) FROM `orders` GROUP BY `id` HAVING COUNT(*) > 1 LIMIT 1
|
|
119
|
+
-- source: per-segment count + hash (one per segment)
|
|
120
|
+
SELECT COUNT(*), ((sum(((('x' || substr(md5(("id"::text) || E'\x1f' || ...
|
|
121
|
+
-- target: per-segment count + hash (one per segment)
|
|
122
|
+
SELECT COUNT(*), ((sum(toInt256(reinterpretAsInt64(reverse(unhex(substr(lower(hex(MD5(...
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Every line above is real output from an actual Postgres/ClickHouse pair — copied verbatim, not hand-written. The hash expressions get long fast (each engine's DEC-1/TS-1 rendering is spelled out in full, no black box); the complete, unedited transcript for this exact table pair is in [docs/explain-output.txt](docs/explain-output.txt).
|
|
126
|
+
|
|
127
|
+
## Exit codes (for CI)
|
|
128
|
+
|
|
129
|
+
| Code | Meaning |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `0` | Tables match |
|
|
132
|
+
| `1` | Differences found |
|
|
133
|
+
| `2` | Could not compare (schema incompatible, missing key, connection failure) |
|
|
134
|
+
|
|
135
|
+
## How is this different from reladiff / data-diff?
|
|
136
|
+
|
|
137
|
+
[reladiff](https://github.com/erezsh/reladiff) is an excellent, actively maintained diffing library, and rowproof uses the same hash-and-bisect idea it and its predecessor `data-diff` popularized. rowproof differs in three ways: every cross-engine type difference is governed by a published rule table and cited in the output; the output is a sign-off report meant to be attached to a cutover approval, not just a diff count; and the CLI is the free core of a hosted reconciliation service (scheduled runs, history, alerts) rather than a standalone library.
|
|
138
|
+
|
|
139
|
+
## Benchmark
|
|
140
|
+
|
|
141
|
+
100M rows, verified correct (exactly the 1,000 differences introduced, nothing else), 127 MB peak client memory, 8.95 minutes on a laptop with both databases sharing the same 8 vCPUs. Full methodology and hardware details in [docs/benchmarks.md](docs/benchmarks.md).
|
|
142
|
+
|
|
143
|
+
## Roadmap
|
|
144
|
+
|
|
145
|
+
- More engines: Databricks, BigQuery, Iceberg, MySQL
|
|
146
|
+
- A hosted reconciliation service: scheduled runs, run history, Slack/email alerts, sign-off reports for a whole migration. Waitlist link coming soon.
|
|
147
|
+
|
|
148
|
+
## Licence
|
|
149
|
+
|
|
150
|
+
Apache 2.0.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rowproof"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Prove a database migration or replication didn't lose, add or change a single row."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
"pyyaml>=6.0",
|
|
11
|
+
"jinja2>=3.1",
|
|
12
|
+
"typer>=0.12",
|
|
13
|
+
"rich>=13",
|
|
14
|
+
"psycopg[binary]>=3.1",
|
|
15
|
+
"clickhouse-connect>=0.7",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
snowflake = ["snowflake-connector-python>=3.6"]
|
|
20
|
+
dev = [
|
|
21
|
+
"pytest>=7.0",
|
|
22
|
+
"ruff>=0.4",
|
|
23
|
+
"testcontainers>=4.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
rowproof = "rowproof.cli.main:main"
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["setuptools>=68", "wheel"]
|
|
31
|
+
build-backend = "setuptools.build_meta"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.packages.find]
|
|
34
|
+
include = ["rowproof*"]
|
|
35
|
+
|
|
36
|
+
[tool.pytest.ini_options]
|
|
37
|
+
testpaths = ["tests"]
|
|
38
|
+
pythonpath = ["."]
|
|
39
|
+
markers = [
|
|
40
|
+
"integration: requires a real running Postgres (or other engine) instance",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.ruff]
|
|
44
|
+
line-length = 100
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
File without changes
|