{% test assert_dimension_completeness(
    model, column_name, metric_column_name, global_dimension_name="global"
) %}

    with
        sum_by_dimension as (
            select {{ column_name }}, sum({{ metric_column_name }}) as sum_metric
            from {{ model }}
            group by {{ column_name }}
        ),
        global_sum as (
            select sum({{ metric_column_name }}) as total_metric
            from {{ model }}
            where {{ column_name }} = '{{ global_dimension_name }}'
        )

    select *
    from sum_by_dimension, global_sum
    where sum_by_dimension.sum_metric != global_sum.total_metric

{% endtest %}
