fix: unnamed primary keys dropped and re-added on every incremental run#1554
Closed
sd-db wants to merge 2 commits into
Closed
fix: unnamed primary keys dropped and re-added on every incremental run#1554sd-db wants to merge 2 commits into
sd-db wants to merge 2 commits into
Conversation
Databricks auto-names an unnamed PK, so the model's name=None never matched the catalog and reconciliation issued DROP CONSTRAINT ... CASCADE + re-add every incremental run, silently dropping dependent FKs. Match a PK on its columns alone; a named PK rename is still reconciled. Warn when a foreign key is declared without a name, since unnamed FKs churn the same way.
8b48d09 to
a65475b
Compare
Collaborator
Author
|
/integration-test |
|
Integration tests dispatched for PR #1554 by @sd-db. Track progress in the Actions tab. |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
Integration results for PR #1554 — UC cluster ✅ success · SQL warehouse ✅ success · All-purpose cluster ✅ success · Shard coverage ✅ success |
Collaborator
Author
|
Closed in favour of #1561 |
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.
What
An unnamed primary key (
type: primary_keywith noname) is auto-named by Databricks. On incremental runs the model carriesname=Nonewhile the catalog read carries the server-assigned name, soConstraintsConfig.get_diffnever matched them and issuedDROP CONSTRAINT ... CASCADE+ re-add every run — silently dropping dependent foreign keys (and erroring withTABLE_OR_VIEW_NOT_FOUNDunder concurrent DDL, per the report).This is the same class of bug as #1552 (RELY
expression), on a different non-round-trippable field: thename.Fix
get_diff, not the comparison key.name, since unnamed FKs churn by the same mechanism. Not fixed here: FK columns aren't a unique key, so they can't be safely de-named — assigning anameavoids it.Tests
expression(e.g. RELY) triggers unnecessary constraint drops that crashes on incremental runs #1513 and TABLE_OR_VIEW_NOT_FOUND on constraint DROP during V2 incremental materialization #1333 (verified: reverting only the name-fix makes it fail).Closes #1333.