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

Allows snapshots to have a list as a unique key #182

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AGPapa
Copy link

@AGPapa AGPapa commented Apr 22, 2024

resolves #181
docs dbt-labs/docs.getdbt.com/#

Problem

Currently the unique_key must be a string. It can be a column name or an expression. This PR changes it so it can be a list of column names or expressions.

Solution

This is modeled off of this PR: dbt-labs/dbt-core#4618

It checks if the unique_key is a list and modifies the code based on that. I am open to other approaches if we want something different (maybe turning a string unique_key into an array one element long?).

I couldn't find tests for the existing snapshot macros, so I'm also open to feedback on the best way to add tests for this feature. I have tested this by copying the macros to one of my dbt projects and running it with a modified version of dbt-core that allows a list for the unique_key.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development, and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX

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 this pull request may close these issues.

[Feature] Allow unique_key for snapshots to take a list
2 participants