Skip to content

Improve error messaging for snapshots: unique-key error  #10864

@hope-wat

Description

@hope-wat

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • 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 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood_first_issueStraightforward + self-contained changes, good for new contributors!logging

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions