Migrating away from dbt-utils' not_null_where and unique_where tests

If you’ve upgraded to dbt 0.20.0, you might start seeing a wall of deprecation warnings from dbt-utils:

dbt_utils.not_null_where is no longer supported. Starting in dbt v0.20.0, the built-in not_null test supports a where config.
dbt_utils.unique_where is no longer supported. Starting in dbt v0.20.0, the built-in unique test supports a where config.

Truly, a wall.

As the warning says, all tests now get a where configuration for free :partying_face:. Migrating to the new method is a simple find-and-replace away (with some regex if you want to be fancy).

In your editor of choice, find dbt_utils\.(unique|not_null)_where and replace it with $1, which is the first capture group (the stuff in brackets).

Regex not your thing? You’ll have to do it in two parts, replacing dbt_utils.unique_where and dbt_utils.not_null_where with unique and not_null respectively.

1 Like