Improve error messaging for snapshots: unique-key error
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this your first time submitting a feature request?
- [X] I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
- [X] I have searched the existing issues, and I could not find an existing issue for this feature
- [X] I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion
### Describe the feature
I would like to improve our snapshot error messaging to improve developer experience so they know the next logical step to take in altering their code.
When you pass a `unique_key` that isn't actually unique you get the error:
```
Duplicate row detected during DML action
Row Values: [redacted]
compiled code at target/run/central_data_team_partner_eng_inc/snapshots/snapshots_testing/vendor_snapshot.yml
```
This currently leads to a rabbit hole of querying data like to uncover the problem when it's actually pretty obvious.
```
SELECT id_given_to_my_unique_key, COUNT(*)
FROM db.schema.table
GROUP BY id_given_to_my_unique_key
HAVING COUNT(*) > 1;
```
I would like this to give a suggestion such as Ensure the unique_key column(s) are really unique.
I think this would better tie out to our [docs](https://docs.getdbt.com/docs/build/snapshots#ensure-your-unique-key-is-really-unique) on this point "Ensure your unique key is really unique".
### Describe alternatives you've considered
Alternatives are to go to the compiled code the error message sends you to. Then you have to go back to your warehouse and find the root cause data.
### Who will this benefit?
All users using snapshots to ensure they are configuring them correctly.
### Are you interested in contributing this feature?
yes if necessary
### Anything else?
This is a low lift improvement to our error messaging that can contribute to user delight!
Contributor guide
Assessment
This issue has not been assessed yet.