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

[CT-2519] [CT-2442] [Bug] Foreign key constraint templating #7417

Closed
Tracked by #7372
Assignees
Labels
bug Something isn't working jira model_contracts Team:Adapters Issues designated for the adapter area of the code
Milestone

Comments

@jtcohen6
Copy link
Contributor

The most common syntax I see is:

  • column level ("inline"): references {expression}
  • model level ("out-of-line"): foreign key {column_list} references {expression}

Right now we're templating this out as foreign_key, instead of references.

Docs:

FWIW on BigQuery it does seem to be foreign_key and NOT references: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_2


If we were to take FK constraints more seriously, we're missing a pretty important ingredient, which is the ability to include & template ref inside the expression field — or providing more structure, i.e.

constraints:
  - type: foreign_key
    ref_table_name: ref('other_table_name')
    ref_column_names: ['id'] # could be multiple

Per #6754 (comment), we kicked that out of scope for v1.5, and we're unlikely to prioritize it while this remains a metadata-only (nonfunctional & unenforceable) feature on the majority of data platforms.

@jtcohen6 jtcohen6 added bug Something isn't working Team:Adapters Issues designated for the adapter area of the code model_contracts labels Apr 20, 2023
@github-actions github-actions bot changed the title [Bug] Foreign key constraint templating [CT-2442] [Bug] Foreign key constraint templating Apr 20, 2023
@jtcohen6 jtcohen6 modified the milestones: v1.5, v1.5.x Apr 25, 2023
@jtcohen6 jtcohen6 assigned jtcohen6 and unassigned jtcohen6 May 3, 2023
@github-actions github-actions bot changed the title [CT-2442] [Bug] Foreign key constraint templating [CT-2519] [CT-2442] [Bug] Foreign key constraint templating May 3, 2023
@MichelleArk MichelleArk self-assigned this May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment