Addressed comments
This commit is contained in:
parent
21858d4d59
commit
64c3c6d1f0
8 changed files with 75 additions and 54 deletions
|
|
@ -81,10 +81,16 @@ Please note that strings should be encoded with " ' your_value_here ' ",
|
|||
{{ return({"dimension": "'by_dash_source'", "dimension_value": "dash_source"}) }}
|
||||
{% endmacro %}
|
||||
{% macro dim_has_payment() %}
|
||||
{{ return({"dimension": "'by_has_payment'", "dimension_value": "'has_payment'"}) }}
|
||||
{{ return({
|
||||
"dimension": "'by_has_payment'",
|
||||
"dimension_value": "case when has_payment then 'True' else 'False' end"
|
||||
}) }}
|
||||
{% endmacro %}
|
||||
{% macro dim_has_id_check() %}
|
||||
{{ return({"dimension": "'by_has_id_check'", "dimension_value": "'has_id_check'"}) }}
|
||||
{{ return({
|
||||
"dimension": "'by_has_id_check'",
|
||||
"dimension_value": "case when has_id_check then 'True' else 'False' end"
|
||||
}) }}
|
||||
{% endmacro %}
|
||||
|
||||
/*
|
||||
|
|
@ -114,7 +120,7 @@ Provides a general assignemnt for the Dimensions available for each KPI
|
|||
{% endif %}
|
||||
|
||||
{# Add entity-specific dimensions #}
|
||||
{% if entity_name == "GUEST_JOURNEY_METRICS" %}
|
||||
{% if entity_name == "CHECK_IN_ATTRIBUTED_GUEST_JOURNEYS" %}
|
||||
{% set additional_dimensions = [dim_has_payment(), dim_has_id_check()] %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,21 @@
|
|||
{% test assert_dimension_completeness(
|
||||
model, column_name, metric_column_names, global_dimension_name="global"
|
||||
model, column_name, metric_column_name, global_dimension_name="global"
|
||||
) %}
|
||||
|
||||
with
|
||||
|
||||
{% for metric_column_name in metric_column_names %}
|
||||
sum_by_dimension_{{ metric_column_name }} as (
|
||||
sum_by_dimension as (
|
||||
select {{ column_name }}, sum({{ metric_column_name }}) as sum_metric
|
||||
from {{ model }}
|
||||
group by {{ column_name }}
|
||||
),
|
||||
global_sum_{{ metric_column_name }} as (
|
||||
global_sum as (
|
||||
select sum({{ metric_column_name }}) as total_metric
|
||||
from {{ model }}
|
||||
where {{ column_name }} = '{{ global_dimension_name }}'
|
||||
),
|
||||
discrepancy_{{ metric_column_name }} as (
|
||||
select *
|
||||
from sum_by_dimension_{{ metric_column_name }}, global_sum_{{ metric_column_name }}
|
||||
where sum_by_dimension_{{ metric_column_name }}.sum_metric != global_sum_{{ metric_column_name }}.total_metric
|
||||
)
|
||||
{% if not loop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for metric_column_name in metric_column_names %}
|
||||
{% if loop.first %}
|
||||
select * from discrepancy_{{ metric_column_name }}
|
||||
{% else %}
|
||||
union all
|
||||
select * from discrepancy_{{ metric_column_name }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
select *
|
||||
from sum_by_dimension, global_sum
|
||||
where sum_by_dimension.sum_metric != global_sum.total_metric
|
||||
|
||||
{% endtest %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue