Add db_query_compare tool for SQL result set comparison#2
Open
frankhereford wants to merge 3 commits intofrank/db-profiling-toolingfrom
Open
Add db_query_compare tool for SQL result set comparison#2frankhereford wants to merge 3 commits intofrank/db-profiling-toolingfrom
frankhereford wants to merge 3 commits intofrank/db-profiling-toolingfrom
Conversation
- Introduced a new Python script `compare_queries.py` for comparing result sets from two SQL files against a database. - Added example SQL query files `query_one.txt` and `query_two.txt` for testing. - Included a `.gitignore` file to exclude `__pycache__` directories. - Updated `requirements.txt` to include `psycopg` for database connectivity.
There was a problem hiding this comment.
Pull request overview
Adds a new toolbox/db_query_compare utility to execute two SQL files against the same PostgreSQL database and report row/field-level differences, intended to support validating query rewrites (e.g., comparing old vs. new SQL outputs).
Changes:
- Introduces
compare_queries.pyCLI script to run both queries and print detailed mismatch diagnostics with exit codes suitable for scripting. - Adds
psycopg[binary]dependency and a minimal.gitignorefor Python bytecode. - Adds two bundled SQL files (
query_one.txt,query_two.txt) as default inputs for the tool.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| toolbox/db_query_compare/compare_queries.py | New Python CLI that runs both SQL files and compares result schemas/rows with detailed diff reporting. |
| toolbox/db_query_compare/requirements.txt | Adds psycopg dependency needed to connect to PostgreSQL. |
| toolbox/db_query_compare/query_one.txt | Bundled default “query one” SQL input for the comparison tool. |
| toolbox/db_query_compare/query_two.txt | Bundled default “query two” SQL input for the comparison tool. |
| toolbox/db_query_compare/.gitignore | Ignores __pycache__/ under the new tool directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
In the course of working on the Moped PR 1840, I needed a tool which would compare and report on the differences in SQL result sets, at a field by field level. This is that tool. It is almost entirely written via 🤖 and to me, it has been a good example of how one-off tools are more at our fingertips than they have ever been.
Testing
-hflag for help and my most recent invocation looks like this, aimed my local moped DB: