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

Closed
wants to merge 5 commits into from

Conversation

AGPapa
Copy link
Contributor

@AGPapa AGPapa commented Apr 22, 2024

resolves #181

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
  • [s] This PR includes tests, or tests are not required/relevant for this PR
  • [s] 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

@gshank gshank requested a review from a team as a code owner June 12, 2024 20:55
@cla-bot cla-bot bot added the cla:yes label Jun 12, 2024
@gshank
Copy link
Contributor

gshank commented Jun 18, 2024

AGPapa: We need a suite of tests for this, including for the supported adapters. At this point that's kind of a complicated process, so we're going to take your supplied patch and manage the rest of it internally. We've put this on the schedule to be estimated and scheduled, and will keep you informed.

@AGPapa
Copy link
Contributor Author

AGPapa commented Jun 21, 2024

Thank you @gshank - let me know

@colin-rogers-dbt colin-rogers-dbt added the community This PR is from a community member label Jul 11, 2024
@colin-rogers-dbt colin-rogers-dbt added the snapshots Issues related to dbt's snapshot functionality label Aug 9, 2024
@gshank gshank closed this Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes community This PR is from a community member snapshots Issues related to dbt's snapshot functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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