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

dbt-bigquery supports and enforces primary key constraints #4419

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

dbeatty10
Copy link
Contributor

@dbeatty10 dbeatty10 commented Nov 8, 2023

Previews

What are you changing in this pull request and why?

@bnaul called out here that some documentation isn't in alignment with the source code (which asserts that dbt-bigquery supports and enforces primary key constraints).

Here are some other docs that should all be in alignment, but aren't:

Model contracts: Platform constraint support

https://docs.getdbt.com/docs/collaborate/govern/model-contracts#platform-constraint-support

image

constraints: Platform-specific support

https://docs.getdbt.com/reference/resource-properties/constraints#platform-specific-support

image

Checklist

  • Review the Content style guide and About versioning so my content adheres to these guidelines.
  • I've checked that the preview renders correctly
  • I've checked that that code behaves as described

Copy link

vercel bot commented Nov 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 16, 2023 3:19pm

@github-actions github-actions bot added content Improvements or additions to content size: x-small This change will take under 3 hours to fix. labels Nov 8, 2023
@bnaul
Copy link

bnaul commented Nov 8, 2023

Primary (and foreign) keys are supported but not enforced in BQ, so I think you only want the first change

@dbeatty10
Copy link
Contributor Author

dbeatty10 commented Nov 8, 2023

Primary (and foreign) keys are supported but not enforced in BQ, so I think you only want the first change

Thank you!

Appreciate you pointing out that in BigQuery Key Constraints are not enforced and are only so the query optimizer may use this information to better optimize queries. As such, users will need to have testing in place to ensure primary key fields are unique and not null.

Our source code is currently asserting that they are enforced (?!), so I've reached out to our engineering team for clarification. Guessing that we'll want to update the source code to be this instead:

        ConstraintType.primary_key: ConstraintSupport.NOT_ENFORCED,
        ConstraintType.foreign_key: ConstraintSupport.NOT_ENFORCED,

Once that clarification comes in, will try to update all the different documentation pages and source code so that they are all in alignment.

@bnaul
Copy link

bnaul commented Nov 8, 2023

ah interesting, they most definitely are not 😅
image

Copy link
Contributor

@mirnawong1 mirnawong1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm and preview looks right!

@mirnawong1 mirnawong1 enabled auto-merge November 16, 2023 15:12
@mirnawong1 mirnawong1 merged commit 5ac11fb into current Nov 16, 2023
2 checks passed
@mirnawong1 mirnawong1 deleted the dbeatty/bigquery-primary-key-constraint branch November 16, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto update content Improvements or additions to content size: x-small This change will take under 3 hours to fix.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants