Add new functional_dependency generic test macro#988
Open
edejong-dbc wants to merge 1 commit into
Open
Conversation
* Provide passing/failing seed CSVs (`data_test_functional_dependency_pass.csv` and `data_test_functional_dependency_fail.csv`) * Add example `schema.yml` usage demonstrating `data_tests` with multiple determinants and an optional `where` clause * Write documentation block for `functional_dependency`. * Upgrade postgres in Docker to 13.19 to be able to run the tests on ARM architectures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #989
Problem
Currently, dbt-utils does not provide a built-in test to ensure that a set of columns (the “determinants”) functionally determines a single “dependent” column. This can be important for validating data integrity, for example, to confirm that every (order_id, product_id) maps to exactly one quantity.
Solution
Adds a new functional_dependency test under macros/generic_tests/.
This test checks that there is exactly one distinct dependent value for each unique combination of determinant columns.
Optionally allows filtering records via a where clause.
Includes example seed CSVs showing both passing and failing scenarios (test_functional_dependency_pass.csv and test_functional_dependency_fail.csv).
Adds a sample schema.yml demonstrating usage with data_tests, how to specify multiple determinant columns, and how to apply a custom where condition.
Provides documentation for the new test following dbt-utils conventions, describing arguments, usage patterns, and an example snippet similar to the style used in other generic tests.
Checklist