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"}) }}
|
{{ return({"dimension": "'by_dash_source'", "dimension_value": "dash_source"}) }}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{% macro dim_has_payment() %}
|
{% 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 %}
|
{% endmacro %}
|
||||||
{% macro dim_has_id_check() %}
|
{% 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 %}
|
{% endmacro %}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -114,7 +120,7 @@ Provides a general assignemnt for the Dimensions available for each KPI
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Add entity-specific dimensions #}
|
{# 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()] %}
|
{% set additional_dimensions = [dim_has_payment(), dim_has_id_check()] %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,21 @@
|
||||||
{% test assert_dimension_completeness(
|
{% 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
|
with
|
||||||
|
sum_by_dimension as (
|
||||||
{% for metric_column_name in metric_column_names %}
|
|
||||||
sum_by_dimension_{{ metric_column_name }} as (
|
|
||||||
select {{ column_name }}, sum({{ metric_column_name }}) as sum_metric
|
select {{ column_name }}, sum({{ metric_column_name }}) as sum_metric
|
||||||
from {{ model }}
|
from {{ model }}
|
||||||
group by {{ column_name }}
|
group by {{ column_name }}
|
||||||
),
|
),
|
||||||
global_sum_{{ metric_column_name }} as (
|
global_sum as (
|
||||||
select sum({{ metric_column_name }}) as total_metric
|
select sum({{ metric_column_name }}) as total_metric
|
||||||
from {{ model }}
|
from {{ model }}
|
||||||
where {{ column_name }} = '{{ global_dimension_name }}'
|
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 %}
|
select *
|
||||||
{% if loop.first %}
|
from sum_by_dimension, global_sum
|
||||||
select * from discrepancy_{{ metric_column_name }}
|
where sum_by_dimension.sum_metric != global_sum.total_metric
|
||||||
{% else %}
|
|
||||||
union all
|
|
||||||
select * from discrepancy_{{ metric_column_name }}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% endtest %}
|
{% 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(
|
config(
|
||||||
|
|
@ -27,9 +27,9 @@
|
||||||
sum(created_guest_journeys) as created_guest_journeys,
|
sum(created_guest_journeys) as created_guest_journeys,
|
||||||
sum(started_guest_journeys) as started_guest_journeys,
|
sum(started_guest_journeys) as started_guest_journeys,
|
||||||
sum(completed_guest_journeys) as completed_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
|
group by 1, 2, 3, 4
|
||||||
{% if not loop.last %}
|
{% if not loop.last %}
|
||||||
union all
|
union all
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
@ -27,9 +27,9 @@
|
||||||
sum(created_guest_journeys) as created_guest_journeys,
|
sum(created_guest_journeys) as created_guest_journeys,
|
||||||
sum(started_guest_journeys) as started_guest_journeys,
|
sum(started_guest_journeys) as started_guest_journeys,
|
||||||
sum(completed_guest_journeys) as completed_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
|
group by 1, 2, 3, 4
|
||||||
{% if not loop.last %}
|
{% if not loop.last %}
|
||||||
union all
|
union all
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{{
|
{{
|
||||||
config(
|
config(
|
||||||
materialized="view",
|
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
|
sum(b.completed_guest_journeys) as completed_guest_journeys
|
||||||
from {{ ref("int_kpis__dimension_dates") }} d
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
left join
|
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
|
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
|
where d.is_end_of_month = true and b.id_deal is not null
|
||||||
group by 1, 2, 3, 4, 5, 6, 7
|
group by 1, 2, 3, 4, 5, 6, 7
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{{
|
{{
|
||||||
config(
|
config(
|
||||||
materialized="view",
|
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
|
sum(b.completed_guest_journeys) as completed_guest_journeys
|
||||||
from {{ ref("int_kpis__dimension_dates") }} d
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
left join
|
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
|
on date_trunc('month', b.date)::date = d.first_day_month
|
||||||
and extract(day from b.date) <= d.day
|
and extract(day from b.date) <= d.day
|
||||||
where d.is_month_to_date = true and b.id_deal is not null
|
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.
|
description: The dimension or granularity of the metrics.
|
||||||
tests:
|
tests:
|
||||||
- assert_dimension_completeness:
|
- assert_dimension_completeness:
|
||||||
metric_column_names:
|
metric_column_name: created_bookings
|
||||||
- created_bookings
|
|
||||||
- accepted_values:
|
- accepted_values:
|
||||||
values:
|
values:
|
||||||
- global
|
- global
|
||||||
|
|
@ -3242,7 +3241,13 @@ models:
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
- accepted_values:
|
- 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
|
- name: main_billing_country_iso_3_per_deal
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
|
|
@ -3332,16 +3337,25 @@ models:
|
||||||
The dimension or granularity of the metrics.
|
The dimension or granularity of the metrics.
|
||||||
tests:
|
tests:
|
||||||
- assert_dimension_completeness:
|
- assert_dimension_completeness:
|
||||||
metric_column_names:
|
metric_column_name: created_guest_journeys_not_cancelled
|
||||||
- created_guest_journeys_not_cancelled
|
- assert_dimension_completeness:
|
||||||
- started_guest_journeys_not_cancelled
|
metric_column_name: started_guest_journeys_not_cancelled
|
||||||
- completed_guest_journeys_not_cancelled
|
- assert_dimension_completeness:
|
||||||
- created_guest_journeys
|
metric_column_name: completed_guest_journeys_not_cancelled
|
||||||
- started_guest_journeys
|
- assert_dimension_completeness:
|
||||||
- completed_guest_journeys
|
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:
|
- accepted_values:
|
||||||
values: ["global", "by_deal", "by_has_payment", "by_has_id_check",
|
values:
|
||||||
"by_billing_country", "by_number_of_listings"]
|
- global
|
||||||
|
- by_deal
|
||||||
|
- by_has_payment
|
||||||
|
- by_has_id_check
|
||||||
|
- by_billing_country
|
||||||
|
- by_number_of_listings
|
||||||
|
|
||||||
- name: dimension_value
|
- name: dimension_value
|
||||||
data_type: text
|
data_type: text
|
||||||
|
|
@ -3461,7 +3475,13 @@ models:
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
- accepted_values:
|
- 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
|
- name: main_billing_country_iso_3_per_deal
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
|
|
@ -3551,16 +3571,25 @@ models:
|
||||||
The dimension or granularity of the metrics.
|
The dimension or granularity of the metrics.
|
||||||
tests:
|
tests:
|
||||||
- assert_dimension_completeness:
|
- assert_dimension_completeness:
|
||||||
metric_column_names:
|
metric_column_name: created_guest_journeys_not_cancelled
|
||||||
- created_guest_journeys_not_cancelled
|
- assert_dimension_completeness:
|
||||||
- started_guest_journeys_not_cancelled
|
metric_column_name: started_guest_journeys_not_cancelled
|
||||||
- completed_guest_journeys_not_cancelled
|
- assert_dimension_completeness:
|
||||||
- created_guest_journeys
|
metric_column_name: completed_guest_journeys_not_cancelled
|
||||||
- started_guest_journeys
|
- assert_dimension_completeness:
|
||||||
- completed_guest_journeys
|
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:
|
- accepted_values:
|
||||||
values: ["global", "by_deal", "by_has_payment", "by_has_id_check",
|
values:
|
||||||
"by_billing_country", "by_number_of_listings"]
|
- global
|
||||||
|
- by_deal
|
||||||
|
- by_has_payment
|
||||||
|
- by_has_id_check
|
||||||
|
- by_billing_country
|
||||||
|
- by_number_of_listings
|
||||||
|
|
||||||
- name: dimension_value
|
- name: dimension_value
|
||||||
data_type: text
|
data_type: text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue