From b1f52719b4d5e7e96d0ab0b4bcfde18378502abf Mon Sep 17 00:00:00 2001 From: jasnonaz Date: Fri, 17 Sep 2021 06:57:39 -0400 Subject: [PATCH] fix: not_null_proportion test deprecation warning and performance (#416) * fix to make not-null-proportion work as intended and remove decpration warning; * fix for object type in excluded columns * clean up namespace formatting * fix to make not-null-proportion work as intended and remove decpration warning; * remove utils.star from separate change * remove utils.star from unrelated change Co-authored-by: Jason Ganx --- macros/schema_tests/not_null_proportion.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/macros/schema_tests/not_null_proportion.sql b/macros/schema_tests/not_null_proportion.sql index 20cb0258..45b9050c 100644 --- a/macros/schema_tests/not_null_proportion.sql +++ b/macros/schema_tests/not_null_proportion.sql @@ -1,5 +1,5 @@ {% macro test_not_null_proportion(model) %} - {{ return(adapter.dispatch('test_not_null_proportion', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }} + {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, **kwargs)) }} {% endmacro %} {% macro default__test_not_null_proportion(model) %} @@ -9,7 +9,7 @@ {% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %} with validation as ( - select + select sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion from {{ model }} ), @@ -19,8 +19,8 @@ validation_errors as ( from validation where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }} ) -select - count(*) +select + * from validation_errors {% endmacro %}