Two SQL queries can look equivalent and return different answers. Query Witness finds a small, valid DuckDB database that shows the difference and saves it for replay.
Preparing an example…
A concrete example
An unassigned support ticket still exists. COUNT(*) counts it; COUNT(assignee_id) skips it because the assignee is NULL. That single row shows why the queries aren’t equivalent.
My contribution
I directed AI implementation agents and worked through examples to question the results. Separate reviews caught correctness problems we then fixed, including a timeout in the final comparison that could be reported as a completed result.
Kept deliberately small
The tool supports one table with up to two integer columns and a restricted SQL subset. It finds differences you can inspect. If the search runs out of time or attempts, that doesn’t prove the queries equivalent.
Releases
All on GitHubReplay requires format_version to be the integer 1 (true and 1.0 are rejected). The witness size cap is 1 MiB of UTF-8 bytes. Schema types INT4 and INT32 are rejected; only INTEGER and INT remain. DuckDB Query interrupted is treated as cancellation, not a finished search.
Query Witness finds small, valid DuckDB databases where two queries disagree, reduces the data, and exports a replayable witness.