From 4a5f604a5b5c74e54caaa0112fddb4bdc3b0adbd Mon Sep 17 00:00:00 2001 From: LE QUANG ANH <10823747+light-le@users.noreply.github.com> Date: Wed, 19 Feb 2025 09:19:20 +0700 Subject: [PATCH] fix equal_rowcount add coalesce to count_a and count_b before taking absolute difference so it doesn't result as null --- macros/generic_tests/equal_rowcount.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/generic_tests/equal_rowcount.sql b/macros/generic_tests/equal_rowcount.sql index 600eae23..b4165813 100644 --- a/macros/generic_tests/equal_rowcount.sql +++ b/macros/generic_tests/equal_rowcount.sql @@ -5,7 +5,7 @@ {% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %} {#-- Needs to be set at parse time, before we return '' below --#} -{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }} +{{ config(fail_calc = 'sum(diff_count)') }} {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} {%- if not execute -%} @@ -60,7 +60,7 @@ final as ( count_a, count_b, - abs(count_a - count_b) as diff_count + abs(coalesce(count_a, 0) - coalesce(count_b, 0)) as diff_count from a full join b