Skip to content

Commit

Permalink
fix equal_rowcount
Browse files Browse the repository at this point in the history
add coalesce to count_a and count_b before taking absolute difference so it doesn't result as null
  • Loading branch information
light-le authored Feb 19, 2025
1 parent 5c9dc0d commit 4a5f604
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions macros/generic_tests/equal_rowcount.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a5f604

Please sign in to comment.