feat(dsql): enhance query plan explainability with type coercion detection, rewrites, and workflow extraction#162
Open
Morlej wants to merge 5 commits into
Open
Conversation
…ction and rewrite references - Add structured trigger phrases and routing criteria for query plan diagnosis - Add type coercion index bypass detection (implicit cast compatibility matrix) - Extend catalog queries with indexed column type retrieval - Add generic SQL rewrite reference (11 patterns: OR-to-IN, subquery unnesting, etc.) - Add DSQL-specific rewrite reference (reltuples estimate, split large joins for DP threshold) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract Workflow 8 (query plan explainability) from SKILL.md into references/query-plan/workflow.md to stay under the 300 LOC limit - Wire query-rewrites-generic.md and query-rewrites-dsql-specific.md into the workflow (Phase 0 load list + Phase 2 evidence gathering) - Add behavioral evals (query_plan_rewrite_evals.json) covering type coercion detection, subquery unnesting, OR-to-IN, GROUP BY pushdown, large join splitting, and reltuples estimation - Add eval results (query_plan_rewrite_eval_results.md) with with-skill vs baseline comparison Validation: - validate-size.py: 275 lines (good) - validate-references.py: 0 broken links, 0 new orphans Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8e33741 to
8261713
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
amaksimo
reviewed
May 11, 2026
Contributor
amaksimo
left a comment
There was a problem hiding this comment.
I have a few general commets:
- We should use positive language throughout (llm can confuse DO with DO NOT when we trim context)
- We should try to use RFC language more frequently throughout
- We should break up the references in the query-plan folder as some of the files are very long
amaksimo
reviewed
May 11, 2026
amaksimo
reviewed
May 11, 2026
amaksimo
reviewed
May 11, 2026
…, RFC keywords
Review feedback from amaksimo:
- Split query-rewrites-generic.md into 11 individual files under
query-rewrites/ subdirectory to reduce context consumption
- Split query-rewrites-dsql-specific.md into individual files
- Convert monolithic files to index tables pointing to sub-files
- Fix DATEADD() SQL Server syntax → PostgreSQL NOW() - INTERVAL
- Flip negative language ("Do not apply") to positive ("Skip when")
- Add RFC keywords (MUST, SHOULD, MAY) throughout
- Remove psql fallback from workflow.md (enforce MCP usage)
- Update plan-interpretation.md recommendation template with RFC language
- Make Phase 0 loading explicit: MUST for core refs, SHOULD for rewrites
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
references/query-plan/workflow.md(SKILL.md: 334 → 275 LOC)plan-interpretation.md, indexed column type queries incatalog-queries.mdquery-rewrites-generic.md(11 patterns: OR-to-IN, subquery unnesting, LEFT-to-INNER JOIN, GROUP BY pushdown, etc.) andquery-rewrites-dsql-specific.md(reltuples estimate, split large joins for DP threshold)Validation
validate-size.py: 275 lines (good, under 300 limit)validate-references.py: 0 broken links, 0 new orphansEval Results
Behavioral with-skill vs baseline comparison (full results in
tools/evals/databases-on-aws/dsql/query_plan_rewrite_eval_results.md):By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.
🤖 Generated with Claude Code