Merged PR 4411: Propagates New Dash/Old Dash/APIs split in KPIs as per Business Scope
# Description Changes: * Adapt business_kpis_configuration to include By Business Scope as production dimension. * Sets in int_mtd_metrics_vs_previous_year the selection of business scope dimension for all KPIs models. This does not affect cross kpis models (churn/mrr). I might need to check later how to adapt Churn to include this dimension, but it's not considered as for this PR. Lastly, Billable Bookings excludes New Dash. * Adapts condition in int_mtd_metrics_vs_previous_year so MTD values would appear independently of these appearing in the previous year. This is, the model was considering that to show current month MTD values, the dimension needed to exist the year prior. This does not happen with New Dash and I assume we never noticed because in any case, most of our dimensions have quite a long history. * Adapts int_kpis__agg_dates_main_kpis to include the business scope dimension. By the way it's actually handled, it kind of assumes that a Deal can only be in New or Old Dash (this is correct), but while on New Dash, this deal won't have data for Old Dash (this might not be 100% correct). In any case, the global figure should be ok, and only on the deal + business scope dimensionality this could cause some potential problems. However, this is not being reported anyway at the moment. * Adapts int_kpis__agg_dates_main_kpis to have a proper variable value for the dimensions, and this is further included in business_kpis_configuration as any other model. Small changes: * Adapts Churn metrics to read from dimension_deals rather than core__deals. This should be more accurate anyway. # Checklist - [ ] The edited models and dependants run properly with production data. - [ ] The edited models are sufficiently documented. - [ ] The edited models contain PK tests, and I've ran and passed them. - [ ] I have checked for DRY opportunities with other models and docs. - [ ] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Propagates New Dash/Old Dash/APIs split in KPIs as per Business Scope Related work items: #27356
This commit is contained in:
parent
7f9ff85b44
commit
be0b8c41b6
6 changed files with 54 additions and 27 deletions
|
|
@ -16,7 +16,7 @@ with
|
|||
int_kpis__dimension_daily_accommodation as (
|
||||
select * from {{ ref("int_kpis__dimension_daily_accommodation") }}
|
||||
),
|
||||
int_core__deal as (select * from {{ ref("int_core__deal") }}),
|
||||
int_kpis__dimension_deals as (select * from {{ ref("int_kpis__dimension_deals") }}),
|
||||
churn_metrics_per_date as (
|
||||
{% for dimension in dimensions %}
|
||||
select
|
||||
|
|
@ -52,7 +52,7 @@ with
|
|||
and m12wc.date = dda.date
|
||||
{% elif dimension.dimension == "'by_billing_country'" %}
|
||||
inner join
|
||||
int_core__deal ud
|
||||
int_kpis__dimension_deals ud
|
||||
on m12wc.id_deal = ud.id_deal
|
||||
and ud.main_billing_country_iso_3_per_deal is not null
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -8,98 +8,100 @@ with
|
|||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_created_bookings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_created_bookings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
check_out_bookings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_check_out_bookings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_check_out_bookings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
billable_bookings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_billable_bookings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_billable_bookings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
-- TEMPORARY EXCLUDE NEW DASH BILLABLE BOOKINGS
|
||||
and dimension_value <> 'New Dash'
|
||||
),
|
||||
created_guest_journeys as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_created_guest_journeys") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_created_guest_journeys") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
started_guest_journeys as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_started_guest_journeys") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_started_guest_journeys") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
completed_guest_journeys as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_completed_guest_journeys") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_completed_guest_journeys") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
guest_journeys_with_payment as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_guest_journeys_with_payment") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_guest_journeys_with_payment") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
listings as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_daily_listings") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
and (is_month_to_date = true or is_end_of_month = true)
|
||||
),
|
||||
|
|
@ -107,7 +109,7 @@ with
|
|||
select *
|
||||
from {{ ref("int_kpis__agg_daily_deals") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
and (is_month_to_date = true or is_end_of_month = true)
|
||||
),
|
||||
|
|
@ -115,39 +117,39 @@ with
|
|||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_guest_payments") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_guest_payments") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
invoiced_revenue as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_invoiced_revenue") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_invoiced_revenue") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
host_resolutions as (
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_mtd_host_resolutions") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
union all
|
||||
select *
|
||||
from {{ ref("int_kpis__agg_monthly_host_resolutions") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
int_monthly_churn_metrics as (select * from {{ ref("int_monthly_churn_metrics") }}),
|
||||
|
|
@ -155,7 +157,7 @@ with
|
|||
select *
|
||||
from {{ ref("int_kpis__agg_dates_main_kpis") }}
|
||||
where
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
dimension in ('global', 'by_number_of_listings', 'by_billing_country', 'by_business_scope')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
int_monthly_onboarding_mrr_per_deal as (
|
||||
|
|
@ -612,5 +614,5 @@ left join
|
|||
where
|
||||
(
|
||||
current.is_end_of_month = true
|
||||
or (current.is_current_month = true and current.day = previous_year.day)
|
||||
or (current.is_current_month = true and (current.day = previous_year.day or previous_year.day is null))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ models:
|
|||
- global
|
||||
- by_number_of_listings
|
||||
- by_billing_country
|
||||
- by_business_scope
|
||||
|
||||
- name: dimension_value
|
||||
data_type: string
|
||||
|
|
@ -253,6 +254,7 @@ models:
|
|||
- global
|
||||
- by_number_of_listings
|
||||
- by_billing_country
|
||||
- by_business_scope
|
||||
|
||||
- name: dimension_value
|
||||
data_type: string
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("MAIN_KPIS_DATES") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
@ -11,6 +11,20 @@ with
|
|||
ikdd.date,
|
||||
-- Dimensions --
|
||||
coalesce(ikd_deals.id_deal, 'UNSET') as id_deal,
|
||||
case
|
||||
when ikd_deals.client_type = 'API'
|
||||
then 'API'
|
||||
when ikd_deals.client_type = 'PLATFORM'
|
||||
then
|
||||
case
|
||||
when
|
||||
icnddsd.id_deal is not null
|
||||
and ikdd.date >= icnddsd.min_user_in_new_dash_since_date_utc
|
||||
then 'New Dash'
|
||||
else 'Old Dash'
|
||||
end
|
||||
else 'UNSET'
|
||||
end as business_scope,
|
||||
coalesce(
|
||||
ikd_deals.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||
) as main_billing_country_iso_3_per_deal,
|
||||
|
|
@ -32,6 +46,9 @@ with
|
|||
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
||||
on ikd_deals.id_deal = icmas.id_deal
|
||||
and ikdd.date = icmas.date
|
||||
left join
|
||||
{{ ref("int_core__new_dash_deal_since_date") }} as icnddsd
|
||||
on ikd_deals.id_deal = icnddsd.id_deal
|
||||
where (ikdd.is_month_to_date = true or ikdd.is_end_of_month)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ models:
|
|||
- global
|
||||
- by_number_of_listings
|
||||
- by_billing_country
|
||||
- by_business_scope
|
||||
- by_deal
|
||||
|
||||
- name: dimension_value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue