feat: validate planned constraint name collisions - #360
Closed
Tomoscorbin wants to merge 1 commit into
Closed
Conversation
Owner
Author
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
AddPrimaryKey, giving every planned constraint creation one action formWhy
Databricks uses one case-insensitive constraint-name namespace per schema across tables and constraint kinds. Per-table validation cannot detect two individually valid plans that request the same name. Without a plan-set check, one addition could succeed before a later addition failed, leaving a partially applied sync.
The previous missing-table path also embedded a primary key inside
CreateTable, forcing global validation to treat new-table primary keys as a special case. Normalizing them toAddPrimaryKeykeeps constraint creation uniform.User impact
A dry run now reports planned explicit-name collisions as
ConstraintNameMustBeUniqueInSchemafailures. Real runs reject every affected table before executing any of its statements. Independent tables may still execute, and foreign-key dependents are blocked through the existing dependency mechanism.Unnamed constraints and already-satisfied declarations do not participate. Collisions with unseen or externally managed catalog constraints remain Databricks execution failures.
Validation
uv run pytest -q— 1,284 passed, 78 deselected, 97.15% coverageuv run ruff check .uv run ruff format --check .uv run mypy .uv run lint-importsuv run --group docs sphinx-build -W -b html docs /tmp/delta-engine-pr5-docs