feat(breaking): add column rename detection to schema diff analysis#1282
Draft
feat(breaking): add column rename detection to schema diff analysis#1282
Conversation
Extend ChangeStatus with "renamed" and add rename_map to NodeChange. After column comparison in _diff_select_scope(), detect removed+added column pairs with identical underlying expressions (stripped of alias) and reclassify them as renames. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: even-wei <evenwei@infuseai.io>
Add RenameDetectionTest class with 12 test cases covering: simple rename, bare-to-alias, multiple renames, expression change (not rename), rename + add/remove/modify, no false positives, derived expressions, and ambiguous greedy matching. Update existing test that now correctly detects a rename instead of removed+added. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: even-wei <evenwei@infuseai.io>
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
PR checklist
What type of PR is this?
Feature — adds column rename detection to the breaking change analysis pipeline.
What this PR does / why we need it:
When a dbt model column is renamed (e.g.,
number_of_orders→order_count), the schema diff currently shows it as a separate "removed" + "added" pair. This is noisy and obscures the developer's intent.This PR adds rename detection to the existing breaking change analysis in
_diff_select_scope(). After the column comparison loop identifies removed and added columns, it compares their underlying SQL expressions (stripped of aliases). Columns with identical expressions are paired as renames instead of remove+add.Changes:
recce/models/types.py: Add"renamed"toChangeStatusliteral type; addrename_map: Optional[dict[str, str]]toNodeChangemodelrecce/util/breaking.py: Add_unalias()helper and rename detection logic (~30 lines) in_diff_select_scope()tests/util/test_breaking.py: Add 12 new rename detection tests + update 2 existing testsWhich issue(s) this PR fixes:
Resolves DRC-3185
Special notes for your reviewer:
rename_mapfield onNodeChangehas no consumers yet — it carries metadata for future frontend use.rename_mapcase normalization in adapter, union scoperename_mapmerging, star propagation category escalation for "renamed". All documented in the review report.Does this PR introduce a user-facing change?:
Backend-only change. The
"renamed"status will be surfaced in the UI in a future Phase 3 PR. No user-visible change yet.