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

Extend Missing Primary Key Tests to include dbt.constraints PK test #517

Open
Pirognoe opened this issue Dec 6, 2024 · 1 comment
Open
Labels
enhancement New feature or request triage

Comments

@Pirognoe
Copy link

Pirognoe commented Dec 6, 2024

Describe the feature

I would like to add additional option no. 4 to Missing Primary Key Tests test to include dbt_constraints.primary_key test from https://github.com/Snowflake-Labs/dbt_constraints/tree/main

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

After adding a snippet like below

columns:
      - name: account_sid
        description: Primary key
        data_tests:
          - dbt_utils.at_least_one
          - dbt_constraints.primary_key

I already check my column for PK validity, but for Missing Primary Key Tests I still need to add the following test, which are essentially duplicates of the above

constraints:
          - type: not_null
        data_tests:
          - dbt_constraints.primary_key
          - dbt_utils.at_least_one
          - unique

Who will this benefit?

Teams using both packages

Are you interested in contributing this feature?

@Pirognoe Pirognoe added enhancement New feature or request triage labels Dec 6, 2024
@b-per
Copy link
Collaborator

b-per commented Dec 6, 2024

Can you overwrite the default combination of tests we look at to raise missing PK? https://dbt-labs.github.io/dbt-project-evaluator/latest/customization/overriding-variables/#testing-and-documentation-variables
(just be aware that this var is a list of list (e.g. a list of combination of tests)

I think that having would work and not report error on any table where a columns has dbt_constraints.primary_key set.

[["dbt_constraints.primary_key"], ...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

2 participants