Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 747 primary key autoname #774

Merged
merged 10 commits into from
Aug 20, 2024

Conversation

elca-anh
Copy link
Contributor

Resolves #747

Description

  • Add the relation identifier (i.e. table name) to the auto generated name of constraints
  • For foreign-key constraints, add either the statement of the list of columns including the parent column

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.

@elca-anh elca-anh changed the title Issue 740 primary key autoname Issue 747 primary key autoname Aug 20, 2024
@benc-db
Copy link
Collaborator

benc-db commented Aug 20, 2024

Thanks for opening, will run the test suite to see where we stand.

benc-db
benc-db previously approved these changes Aug 20, 2024
@benc-db benc-db merged commit 55707d3 into databricks:main Aug 20, 2024
18 checks passed
@PtrckGdwn
Copy link

Hi, I am really keen to use the non-expression method for foreign keys. Unfortunately, when I try it, I get an error message like: "No parent table defined for foreign key: " followed by a trace.

I have configured the schema for the model like so:

  - name: example__child_table
    constraints:
      - type: primary_key
        name: pk_example__child_table
        columns: ["id"]
      - type: not_null
        columns: ["id", "name", "parent_id"]
      - type: foreign_key
        name: fk_example__child_table_1
        columns: ["parent_id"]
        parent: parent_table
        parent_columns: ["id"]
    columns:
      - name: id
      - name: name
      - name: parent_id

Any tips on how to get this working? I've had a look at the macro code, and it appears the constraint.get("parent") call is not returning anything, hence the error message, but I can't see anything obvious I am doing wrong.

Running with adaptor version 1.8.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-named constraints does not take into account for the model/table name
3 participants