Connecting to the live runnerβ¦
Query Witness
A Python CLI that finds the data where two SQL queries disagree, then saves a witness you can replay.
Donβt guess. Find the difference.
A rewrite can look right and still return a different answer. Give Query Witness a schema and two queries. It looks for a small, valid database that makes them disagree.
- The input
Start with SQL
A schema and two queries you want to compare.
schema.sql + query-a.sql + query-b.sql - SQLGlot
Check the scope
Reject unsupported SQL before the search starts.
subset.py - Python + DuckDB
Find a difference
Generate valid tables. Run both queries on the same data.
core.py - The output
Keep the witness
Remove unnecessary rows. Export the evidence and replay it.
witness.json + reproduce.sql
One ticket. Two different counts.
This ticket has no assignee. Counting every row includes it. Counting the assignee column skips the NULL.
tickets| ticket_id | assignee_id |
|---|---|
| -1 | NULL |
One valid row. The ID is unique;
the assignee is allowed to be NULL.
COUNT(*)COUNT(assignee_id)Same database. Different results.
The data, both queries, and their results.
query-witness replay witnessUnzip and run with Query Witness 0.1.0, DuckDB 1.5.5, and SQLGlot 30.18.0. This is a constructed example, not a customer incident.
A small stack, with clear jobs.
- PythonCLI, search & replay
- SQLGlotSQL validation
- DuckDBRuns the original SQL
SQL & Bash Β· pytest for tests Β· Hatchling for packaging Β· pip or uv for setup
One table, up to two INTEGER columns, and a restricted SQL subset. A search with no counterexample is not a proof of equivalence. Unsupported input, engine failures, and resource limits are reported separately.