Skip to content

chore(dawgrun): add optimize-cypher command - #120

Merged
seanjSO merged 2 commits into
mainfrom
seanj/dawgrun-optimize-cypher
Aug 19, 2026
Merged

chore(dawgrun): add optimize-cypher command#120
seanjSO merged 2 commits into
mainfrom
seanj/dawgrun-optimize-cypher

Conversation

@seanjSO

@seanjSO seanjSO commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

Adds an optimize-cypher command to dawgrun to inspect the optimization plan, optimization rule applications, and the optimized query. Does not impact production code

Resolves: <TICKET_OR_ISSUE_NUMBER>

Type of Change

  • Chore (a change that does not modify the application functionality)
  • Bug fix (a change that fixes an issue)
  • New feature / enhancement (a change that adds new functionality)
  • Refactor (no behaviour change)
  • Test coverage
  • Build / CI / tooling
  • Documentation

Testing

  • Unit tests added / updated
  • Integration tests added / updated
  • Full test suite run (make test_all with CONNECTION_STRING set)

Screenshots (if appropriate):

Driver Impact

  • PostgreSQL driver (drivers/pg)
  • Neo4j driver (drivers/neo4j)

Checklist

  • Code is formatted
  • All existing tests pass
  • go.mod / go.sum are up to date if dependencies changed

Summary by CodeRabbit

  • New Features

    • Added an optimize-cypher command for analyzing and optimizing Cypher queries.
    • Displays original and optimized queries, applied optimization rules, analysis details, lowering plans, and predicate attachments when available.
    • Provides clear, contextual error messages for parsing, optimization, and formatting issues.
  • Bug Fixes

    • Improved query translation and explanation output for greater consistency.
    • Added optional abstract syntax tree output to translation results.

@seanjSO seanjSO self-assigned this Aug 18, 2026
@seanjSO seanjSO added the go Pull requests that update go code label Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72d7fd9f-df1b-450f-9b13-fcf521997bb6

📥 Commits

Reviewing files that changed from the base of the PR and between 2e3d1b4 and 7991695.

📒 Files selected for processing (1)
  • tools/dawgrun/pkg/commands/cypher_test.go

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

The CLI registers optimize-cypher. The command parses and optimizes Cypher queries, then displays formatted queries, applied rules, analysis, lowering information, and predicate attachments. Existing translation and explain flows use the aliased PostgreSQL formatter.

Changes

Cypher command changes

Layer / File(s) Summary
Formatter alias integration
tools/dawgrun/pkg/commands/cypher.go
Translation and explain flows use the aliased PostgreSQL formatter.
Optimize Cypher command
tools/dawgrun/pkg/commands/cypher.go, tools/dawgrun/pkg/commands/registry.go, tools/dawgrun/pkg/commands/cypher_test.go
optimize-cypher parses and optimizes queries, formats results, reports optimization details, is added to the command registry, and is covered by command tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 79916

This PR adds a localized dawgrun inspection command without changing production application behavior, and no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant optimizeCypherCmd
  participant CypherParser
  participant DefaultOptimizerRules
  participant PostgreSQLFormatter
  CLI->>optimizeCypherCmd: Run optimize-cypher
  optimizeCypherCmd->>CypherParser: Parse Cypher query
  optimizeCypherCmd->>DefaultOptimizerRules: Apply optimization rules
  optimizeCypherCmd->>PostgreSQLFormatter: Format query results
  optimizeCypherCmd-->>CLI: Display queries and optimization details
Loading

Poem

A rabbit hops through query trees,
Finds tidy paths with optimizer ease.
Formats both old and new just right,
Shows every rule in clear daylight.
optimize-cypher takes flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the optimize-cypher command.
Description check ✅ Passed The description covers the change, classification, testing status, driver impact, and checklist using the required template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch seanj/dawgrun-optimize-cypher

Comment @coderabbitai help to get the list of available commands.

@seanjSO
seanjSO force-pushed the seanj/dawgrun-optimize-cypher branch from 46648df to 2e3d1b4 Compare August 18, 2026 18:16

@urangel urangel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Really appreciate how approachable dawgrun makes working in this space

@seanjSO
seanjSO merged commit c2f49d8 into main Aug 19, 2026
9 checks passed
@seanjSO
seanjSO deleted the seanj/dawgrun-optimize-cypher branch August 19, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants