feat: delegate constraint naming to Databricks - #350
Draft
Tomoscorbin wants to merge 4 commits into
Draft
Conversation
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
CREATE TABLEandALTER TABLE ... ADDSQLBehavior
Constraint names now have one narrow meaning:
Once a constraint exists, its name belongs to the catalog. A desired constraint is satisfied by an observed constraint with the same definition, regardless of either name. Changing only
primary_key_nameorForeignKey(name=...)is therefore a no-op.Structural drift still produces a drop and an add. The drop uses the concrete observed name; the add preserves the user's optional creation preference. Existing tables using the old engine-generated naming convention converge without DDL churn.
An explicit name collision during creation remains a Databricks execution error because constraint names share a schema-wide namespace.
Design
PrimaryKeyConstraintandForeignKeyConstraintrepresent desired declarations and carry an optionalnameObservedPrimaryKeyConstraintandObservedForeignKeyConstraintrequire the catalog name, making unnamed observed state unrepresentabledesired_key == observed_keycomparisonValidation
uv run pytest -q: 1,244 passed, 79 deselected; 97.21% coverageuv run mypy src: passeduv run ruff check .: passeduv run ruff format --check .: passeduv run lint-imports: 7 contracts keptuv run --group docs sphinx-build -W -b html docs docs/_build/html: passedgit diff --check: passed