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

Add test to compare distinct counts between tables #48

Closed
jeffwhite-indeed opened this issue Apr 22, 2021 · 2 comments · Fixed by #50
Closed

Add test to compare distinct counts between tables #48

jeffwhite-indeed opened this issue Apr 22, 2021 · 2 comments · Fixed by #50
Labels
enhancement New feature or request

Comments

@jeffwhite-indeed
Copy link

Can we consider a test that would check that all distinct source records are present on a target table? This could confirm that our warehouse isn't missing any ids. I would imagine it might be similar to the expect_table_row_count_to_equal_other_table test, but with a distinct allowed?

@clausherther clausherther added the enhancement New feature or request label Apr 22, 2021
@clausherther clausherther changed the title Request for test to compare distinct counts between tables Add test to compare distinct counts between tables Apr 22, 2021
@clausherther
Copy link
Contributor

This could in theory be accomplished today using the base equal_expression macro, and we can easily wrap this in a more specific "expectation".

  - name: my_model_1
    tests:
        - dbt_expectations.equal_expression:
            expression: count(distinct col1)
            compare_model: ref("my_model_2")
            compare_expression: count(distinct col2)

@jeffwhite-indeed
Copy link
Author

This could in theory be accomplished today using the base equal_expression macro, and we can easily wrap this in a more specific "expectation".

  - name: my_model_1
    tests:
        - dbt_expectations.equal_expression:
            expression: count(distinct col1)
            compare_model: ref("my_model_2")
            compare_expression: count(distinct col2)

Ha. Correct. I missed this macro as I was only reviewing the ones in the README. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants