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

[Bug] infer_primary_key returns an array with None values if a node's unique or unique_combination_of_columns data test is misconfigured #10983

Closed
2 tasks done
MichelleArk opened this issue Nov 6, 2024 · 0 comments · Fixed by #10984
Labels
bug Something isn't working

Comments

@MichelleArk
Copy link
Contributor

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Given a test configured on a model as:

- name: model
  tests:
    - dbt_utils.unique_combination_of_columns:
        combination_of_columns:
          - null

the inferred primary_key on model will result in [null], which violates the manifest schema and may lead to parsing issues down the road: https://schemas.getdbt.com/dbt/manifest/v12/index.html#nodes_additionalProperties_anyOf_i4_primary_key

Expected Behavior

Ideally, dbt-utils can raise a parse-time error. dbt-core itself isn't in a position to validate these contracts though.

In dbt-core it'd be better to return None or an empty list for primary_key instead of an invalid [null] array. dbt-core can also emit a warning log indicating the primary_key could not be inferred for a given model, even though it has a unique_combination_of_columns test.

Steps To Reproduce

in current behaviour.

Relevant log output

No response

Environment

No response

Which database adapter are you using with dbt?

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants