Merged PR 4400: Adds Billable Bookings split per scope

# Description

Changes:
* Adds Business Scope split on Billable Bookings + propagates towards Agg/Metric Monthly/MTD models

This is a temporary modification until the ticket on Billable Bookings for New Dash is handled.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] 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.

Related work items: #27356
This commit is contained in:
Oriol Roqué Paniagua 2025-02-14 12:29:18 +00:00
parent 4b94d5f70b
commit a690ca6eac
5 changed files with 79 additions and 9 deletions

View file

@ -136,17 +136,18 @@ Provides a general assignement for the Dimensions available for each KPI
{# Add entity-specific dimensions #} {# Add entity-specific dimensions #}
{% if entity_name in [ {% if entity_name in [
"BILLABLE_BOOKINGS",
"CHECK_OUT_BOOKINGS", "CHECK_OUT_BOOKINGS",
"COMPLETED_GUEST_JOURNEYS", "COMPLETED_GUEST_JOURNEYS",
"CREATED_BOOKINGS", "CREATED_BOOKINGS",
"CREATED_GUEST_JOURNEYS", "CREATED_GUEST_JOURNEYS",
"DEALS",
"GUEST_JOURNEYS_WITH_PAYMENT", "GUEST_JOURNEYS_WITH_PAYMENT",
"GUEST_PAYMENTS", "GUEST_PAYMENTS",
"STARTED_GUEST_JOURNEYS",
"INVOICED_REVENUE",
"HOST_RESOLUTIONS", "HOST_RESOLUTIONS",
"INVOICED_REVENUE",
"LISTINGS", "LISTINGS",
"DEALS", "STARTED_GUEST_JOURNEYS",
] %} ] %}
{% set additional_dimensions = additional_dimensions + [dim_business_scope()] %} {% set additional_dimensions = additional_dimensions + [dim_business_scope()] %}
{% endif %} {% endif %}

View file

@ -1,8 +1,24 @@
{{ config(materialized="table", unique_key=["date", "id_deal"]) }} {{ config(materialized="table", unique_key=["date", "id_deal", "business_scope"]) }}
select select
-- Unique Key -- -- Unique Key --
icb.booking_fee_charge_date_utc as date, icb.booking_fee_charge_date_utc as date,
coalesce(icuh.id_deal, 'UNSET') as id_deal, coalesce(icuh.id_deal, 'UNSET') as id_deal,
-- ORP here: I'm expecting this to change according to the definition of Billable
-- Bookings expected for New Dash. This is just a temporary placeholder in the
-- same fashion as Booking metrics.
case
-- New Dash users with a booking and a deal
when
icbs.id_booking is not null
and icbs.is_user_in_new_dash = true
and icbs.is_missing_id_deal = false
then 'New Dash'
-- Old Dash users if there is no booking or the user is not in the new dash
when icbs.id_booking is null or icbs.is_user_in_new_dash = false
then 'Old Dash'
-- Rest of the cases, includes KYG Lite users
else 'UNSET'
end as business_scope,
-- Dimensions -- -- Dimensions --
coalesce( coalesce(
icd.main_billing_country_iso_3_per_deal, 'UNSET' icd.main_billing_country_iso_3_per_deal, 'UNSET'
@ -20,5 +36,7 @@ left join
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas {{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
on icuh.id_deal = icmas.id_deal on icuh.id_deal = icmas.id_deal
and icb.booking_fee_charge_date_utc = icmas.date and icb.booking_fee_charge_date_utc = icmas.date
where icb.booking_fee_charge_date_utc is not null left join
group by 1, 2, 3, 4 {{ ref("int_core__booking_summary") }} as icbs on icb.id_booking = icbs.id_booking
where icb.is_duplicate_booking = false and icb.booking_fee_charge_date_utc is not null
group by 1, 2, 3, 4, 5

View file

@ -5,6 +5,7 @@
"end_date", "end_date",
"id_deal", "id_deal",
"active_accommodations_per_deal_segmentation", "active_accommodations_per_deal_segmentation",
"business_scope",
], ],
) )
}} }}
@ -14,6 +15,7 @@ select
d.first_day_month as start_date, d.first_day_month as start_date,
d.date as end_date, d.date as end_date,
b.id_deal, b.id_deal,
b.business_scope,
b.active_accommodations_per_deal_segmentation, b.active_accommodations_per_deal_segmentation,
-- Dimensions -- -- Dimensions --
b.main_billing_country_iso_3_per_deal, b.main_billing_country_iso_3_per_deal,
@ -24,4 +26,4 @@ left join
{{ ref("int_kpis__metric_daily_billable_bookings") }} b {{ ref("int_kpis__metric_daily_billable_bookings") }} 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 group by 1, 2, 3, 4, 5, 6

View file

@ -5,6 +5,7 @@
"end_date", "end_date",
"id_deal", "id_deal",
"active_accommodations_per_deal_segmentation", "active_accommodations_per_deal_segmentation",
"business_scope",
], ],
) )
}} }}
@ -14,6 +15,7 @@ select
d.first_day_month as start_date, d.first_day_month as start_date,
d.date as end_date, d.date as end_date,
b.id_deal, b.id_deal,
b.business_scope,
b.active_accommodations_per_deal_segmentation, b.active_accommodations_per_deal_segmentation,
-- Dimensions -- -- Dimensions --
b.main_billing_country_iso_3_per_deal, b.main_billing_country_iso_3_per_deal,
@ -25,4 +27,4 @@ left join
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
group by 1, 2, 3, 4, 5 group by 1, 2, 3, 4, 5, 6

View file

@ -3304,13 +3304,15 @@ models:
The unique key corresponds to the deepest granularity of the model, The unique key corresponds to the deepest granularity of the model,
in this case: in this case:
- date, - date,
- id_deal. - id_deal,
- business_scope.
data_tests: data_tests:
- dbt_utils.unique_combination_of_columns: - dbt_utils.unique_combination_of_columns:
combination_of_columns: combination_of_columns:
- date - date
- id_deal - id_deal
- business_scope
columns: columns:
- name: date - name: date
@ -3325,6 +3327,19 @@ models:
data_tests: data_tests:
- not_null - not_null
- name: business_scope
data_type: string
description: |
Business scope identifying the metric source.
data_tests:
- not_null
- accepted_values:
values:
- "Old Dash"
- "New Dash"
- "API"
- "UNSET"
- name: active_accommodations_per_deal_segmentation - name: active_accommodations_per_deal_segmentation
data_type: string data_type: string
description: | description: |
@ -3364,6 +3379,7 @@ models:
The unique key corresponds to: The unique key corresponds to:
- end_date, - end_date,
- id_deal, - id_deal,
- business_scope,
- active_accommodations_per_deal_segmentation. - active_accommodations_per_deal_segmentation.
data_tests: data_tests:
@ -3371,6 +3387,7 @@ models:
combination_of_columns: combination_of_columns:
- end_date - end_date
- id_deal - id_deal
- business_scope
- active_accommodations_per_deal_segmentation - active_accommodations_per_deal_segmentation
columns: columns:
@ -3394,6 +3411,19 @@ models:
data_tests: data_tests:
- not_null - not_null
- name: business_scope
data_type: string
description: |
Business scope identifying the metric source.
data_tests:
- not_null
- accepted_values:
values:
- "Old Dash"
- "New Dash"
- "API"
- "UNSET"
- name: active_accommodations_per_deal_segmentation - name: active_accommodations_per_deal_segmentation
data_type: string data_type: string
description: | description: |
@ -3434,6 +3464,7 @@ models:
The unique key corresponds to: The unique key corresponds to:
- end_date, - end_date,
- id_deal, - id_deal,
- business_scope,
- active_accommodations_per_deal_segmentation. - active_accommodations_per_deal_segmentation.
data_tests: data_tests:
@ -3441,6 +3472,7 @@ models:
combination_of_columns: combination_of_columns:
- end_date - end_date
- id_deal - id_deal
- business_scope
- active_accommodations_per_deal_segmentation - active_accommodations_per_deal_segmentation
columns: columns:
@ -3464,6 +3496,19 @@ models:
data_tests: data_tests:
- not_null - not_null
- name: business_scope
data_type: string
description: |
Business scope identifying the metric source.
data_tests:
- not_null
- accepted_values:
values:
- "Old Dash"
- "New Dash"
- "API"
- "UNSET"
- name: active_accommodations_per_deal_segmentation - name: active_accommodations_per_deal_segmentation
data_type: string data_type: string
description: | description: |
@ -3535,6 +3580,7 @@ models:
- global - global
- by_number_of_listings - by_number_of_listings
- by_billing_country - by_billing_country
- by_business_scope
- by_deal - by_deal
- name: dimension_value - name: dimension_value
@ -3589,6 +3635,7 @@ models:
- global - global
- by_number_of_listings - by_number_of_listings
- by_billing_country - by_billing_country
- by_business_scope
- by_deal - by_deal
- name: dimension_value - name: dimension_value