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 %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("GUEST_JOURNEY_METRICS") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("CHECK_IN_ATTRIBUTED_GUEST_JOURNEYS") %}
|
||||
|
||||
{{
|
||||
config(
|
||||
|
|
@ -27,9 +27,9 @@
|
|||
sum(created_guest_journeys) as created_guest_journeys,
|
||||
sum(started_guest_journeys) as started_guest_journeys,
|
||||
sum(completed_guest_journeys) as completed_guest_journeys
|
||||
from {{ ref("int_kpis__metric_mtd_check_in_attrib_guest_journeys") }}
|
||||
from {{ ref("int_kpis__metric_monthly_check_in_attributed_guest_journeys") }}
|
||||
group by 1, 2, 3, 4
|
||||
{% if not loop.last %}
|
||||
union all
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
@ -27,9 +27,9 @@
|
|||
sum(created_guest_journeys) as created_guest_journeys,
|
||||
sum(started_guest_journeys) as started_guest_journeys,
|
||||
sum(completed_guest_journeys) as completed_guest_journeys
|
||||
from {{ ref("int_kpis__metric_monthly_check_in_attrib_guest_journeys") }}
|
||||
from {{ ref("int_kpis__metric_mtd_check_in_attributed_guest_journeys") }}
|
||||
group by 1, 2, 3, 4
|
||||
{% if not loop.last %}
|
||||
union all
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{{
|
||||
config(
|
||||
materialized="view",
|
||||
unique_key=["end_date", "id_deal", "has_payment", "has_id_check"],
|
||||
unique_key=["end_date", "id_deal", "has_payment", "has_id_check", "active_accommodations_per_deal_segmentation"],
|
||||
)
|
||||
}}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ select
|
|||
sum(b.completed_guest_journeys) as completed_guest_journeys
|
||||
from {{ ref("int_kpis__dimension_dates") }} d
|
||||
left join
|
||||
{{ ref("int_kpis__metric_daily_check_in_attrib_guest_journeys") }} b
|
||||
{{ ref("int_kpis__metric_daily_check_in_attributed_guest_journeys") }} b
|
||||
on date_trunc('month', b.date)::date = d.first_day_month
|
||||
where d.is_end_of_month = true and b.id_deal is not null
|
||||
group by 1, 2, 3, 4, 5, 6, 7
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{{
|
||||
config(
|
||||
materialized="view",
|
||||
unique_key=["end_date", "id_deal", "has_payment", "has_id_check"],
|
||||
unique_key=["end_date", "id_deal", "has_payment", "has_id_check", "active_accommodations_per_deal_segmentation"],
|
||||
)
|
||||
}}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ select
|
|||
sum(b.completed_guest_journeys) as completed_guest_journeys
|
||||
from {{ ref("int_kpis__dimension_dates") }} d
|
||||
left join
|
||||
{{ ref("int_kpis__metric_daily_check_in_attrib_guest_journeys") }} b
|
||||
{{ ref("int_kpis__metric_daily_check_in_attributed_guest_journeys") }} b
|
||||
on date_trunc('month', b.date)::date = d.first_day_month
|
||||
and extract(day from b.date) <= d.day
|
||||
where d.is_month_to_date = true and b.id_deal is not null
|
||||
|
|
@ -480,8 +480,7 @@ models:
|
|||
description: The dimension or granularity of the metrics.
|
||||
tests:
|
||||
- assert_dimension_completeness:
|
||||
metric_column_names:
|
||||
- created_bookings
|
||||
metric_column_name: created_bookings
|
||||
- accepted_values:
|
||||
values:
|
||||
- global
|
||||
|
|
@ -3242,7 +3241,13 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ["0", "01-05", "06-20", "21-60", "61+", "UNSET"]
|
||||
values:
|
||||
- "0"
|
||||
- "01-05"
|
||||
- "06-20"
|
||||
- "21-60"
|
||||
- "61+"
|
||||
- "UNSET"
|
||||
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: character varying
|
||||
|
|
@ -3332,16 +3337,25 @@ models:
|
|||
The dimension or granularity of the metrics.
|
||||
tests:
|
||||
- assert_dimension_completeness:
|
||||
metric_column_names:
|
||||
- created_guest_journeys_not_cancelled
|
||||
- started_guest_journeys_not_cancelled
|
||||
- completed_guest_journeys_not_cancelled
|
||||
- created_guest_journeys
|
||||
- started_guest_journeys
|
||||
- completed_guest_journeys
|
||||
metric_column_name: created_guest_journeys_not_cancelled
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: started_guest_journeys_not_cancelled
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: completed_guest_journeys_not_cancelled
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: created_guest_journeys
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: started_guest_journeys
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: completed_guest_journeys
|
||||
- accepted_values:
|
||||
values: ["global", "by_deal", "by_has_payment", "by_has_id_check",
|
||||
"by_billing_country", "by_number_of_listings"]
|
||||
values:
|
||||
- global
|
||||
- by_deal
|
||||
- by_has_payment
|
||||
- by_has_id_check
|
||||
- by_billing_country
|
||||
- by_number_of_listings
|
||||
|
||||
- name: dimension_value
|
||||
data_type: text
|
||||
|
|
@ -3461,7 +3475,13 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ["0", "01-05", "06-20", "21-60", "61+", "UNSET"]
|
||||
values:
|
||||
- "0"
|
||||
- "01-05"
|
||||
- "06-20"
|
||||
- "21-60"
|
||||
- "61+"
|
||||
- "UNSET"
|
||||
|
||||
- name: main_billing_country_iso_3_per_deal
|
||||
data_type: character varying
|
||||
|
|
@ -3551,16 +3571,25 @@ models:
|
|||
The dimension or granularity of the metrics.
|
||||
tests:
|
||||
- assert_dimension_completeness:
|
||||
metric_column_names:
|
||||
- created_guest_journeys_not_cancelled
|
||||
- started_guest_journeys_not_cancelled
|
||||
- completed_guest_journeys_not_cancelled
|
||||
- created_guest_journeys
|
||||
- started_guest_journeys
|
||||
- completed_guest_journeys
|
||||
metric_column_name: created_guest_journeys_not_cancelled
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: started_guest_journeys_not_cancelled
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: completed_guest_journeys_not_cancelled
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: created_guest_journeys
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: started_guest_journeys
|
||||
- assert_dimension_completeness:
|
||||
metric_column_name: completed_guest_journeys
|
||||
- accepted_values:
|
||||
values: ["global", "by_deal", "by_has_payment", "by_has_id_check",
|
||||
"by_billing_country", "by_number_of_listings"]
|
||||
values:
|
||||
- global
|
||||
- by_deal
|
||||
- by_has_payment
|
||||
- by_has_id_check
|
||||
- by_billing_country
|
||||
- by_number_of_listings
|
||||
|
||||
- name: dimension_value
|
||||
data_type: text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue