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

Implement primary key inference for model nodes #9652

Closed
1 task done
MichelleArk opened this issue Feb 23, 2024 · 0 comments · Fixed by #9650
Closed
1 task done

Implement primary key inference for model nodes #9652

MichelleArk opened this issue Feb 23, 2024 · 0 comments · Fixed by #9650
Assignees

Comments

@MichelleArk
Copy link
Contributor

Housekeeping

  • I am a maintainer of dbt-core

Short description

Now that we support both constraints and tests on models, dbt can infer a primary key with the following logic:
1. Columns participating in a model-level primary key constraints
2. Columns with primary key constraints
3. Columns with unique and not_null data tests
4. Columns with enabled unique or dbt_utils.unique_combination_of_columns data tests
5. Columns with disabled unique or dbt_utils.unique_combination_of_columns data tests

Let's start by implementing this as an method to serve as a building block for downstream uses cases such as discovery (e.g. through the manifest), and maybe even sampling?

Acceptance criteria

  • ModelNode.infer_primary_key exists!

Suggested Tests

  • cases in description are covered

Impact to Other Teams

N/A

Will backports be required?

nope

Context

No response

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 a pull request may close this issue.

2 participants