Merged PR 3698: added service_business_type to new_dash_created_services models

# Description

Added service_business_type to new_dash_created_services models.
Points to check on the chargeable_services models:
- I think it also needs to account for `UNKNOWN` values
- Adding the service_business_type to the unique test on the weekly and monthly metric models

```
case
    when icbsd.service_business_type = 'UNKNOWN'
    then 'UNSET'
    else coalesce(icbsd.service_business_type, 'UNSET')
end as service_business_type
```
@<Oriol Roqué Paniagua> Let me know what you think and I can make the changes if needed

# 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.

added service_business_type to new_dash_created_services models

Related work items: #24767
This commit is contained in:
Joaquin Ossa 2024-12-02 11:53:48 +00:00
commit 4c7820608a
8 changed files with 95 additions and 11 deletions

View file

@ -153,6 +153,7 @@ Provides a general assignement for the Dimensions available for each KPI
dim_has_upgraded_service(),
dim_new_dash_version(),
dim_pricing_service(),
dim_pricing_business_type(),
] %}
{% endif %}

View file

@ -1,14 +1,19 @@
{{ config(materialized="table", unique_key=["id_booking", "service_name", "date"]) }}
{{
config(
materialized="table",
unique_key=["id_booking", "service_name", "date", "service_business_type"],
)
}}
select
-- Unique Key --
icbs.id_booking,
icbsd.service_last_chargeable_date_utc as date,
coalesce(icbsd.service_name) as service_name,
coalesce(icbsd.service_business_type, 'UNSET') as service_business_type,
-- Dimensions --
coalesce(icbs.id_deal, 'UNSET') as id_deal,
icbs.id_accommodation,
case when icbsd.is_upgraded_service then 'YES' else 'NO' end as is_upgraded_service,
coalesce(icbsd.service_business_type, 'UNSET') as service_business_type,
coalesce(icbs.new_dash_version, 'UNSET') as new_dash_version,
coalesce(
icd.main_billing_country_iso_3_per_deal, 'UNSET'

View file

@ -1,9 +1,15 @@
{{ config(materialized="table", unique_key=["id_booking", "service_name", "date"]) }}
{{
config(
materialized="table",
unique_key=["id_booking", "service_name", "date", "service_business_type"],
)
}}
select
-- Unique Key --
icbs.id_booking,
date(icbsd.service_detail_created_at_utc) as date,
coalesce(icbsd.service_name) as service_name,
coalesce(icbsd.service_business_type, 'UNSET') as service_business_type,
-- Dimensions --
coalesce(icbs.id_deal, 'UNSET') as id_deal,
case when icbsd.is_upgraded_service then 'YES' else 'NO' end as is_upgraded_service,
@ -30,4 +36,4 @@ where
and icbs.is_missing_id_deal = false
and icbsd.service_detail_created_at_utc
>= icbs.user_in_new_dash_since_timestamp_at_utc
group by 1, 2, 3, 4, 5, 6, 7, 8
group by 1, 2, 3, 4, 5, 6, 7, 8, 9

View file

@ -6,6 +6,7 @@
"service_name",
"id_booking",
"active_accommodations_per_deal_segmentation",
"service_business_type",
],
)
}}
@ -17,10 +18,10 @@ select
cs.id_booking,
cs.service_name,
cs.active_accommodations_per_deal_segmentation,
cs.service_business_type,
-- Dimensions --
cs.id_deal,
cs.id_accommodation,
cs.service_business_type,
cs.new_dash_version,
cs.is_upgraded_service,
cs.main_billing_country_iso_3_per_deal,

View file

@ -6,6 +6,7 @@
"service_name",
"id_deal",
"active_accommodations_per_deal_segmentation",
"service_business_type",
],
)
}}
@ -17,6 +18,7 @@ select
cs.service_name,
cs.active_accommodations_per_deal_segmentation,
cs.id_deal,
cs.service_business_type,
-- Dimensions --
cs.new_dash_version,
cs.is_upgraded_service,
@ -29,4 +31,4 @@ left join
{{ ref("int_kpis__metric_daily_new_dash_created_services") }} cs
on date_trunc('month', cs.date)::date = d.first_day_month
where d.is_end_of_month = true and cs.id_deal is not null
group by 1, 2, 3, 4, 5, 6, 7, 8
group by 1, 2, 3, 4, 5, 6, 7, 8, 9

View file

@ -6,6 +6,7 @@
"id_booking",
"service_name",
"active_accommodations_per_deal_segmentation",
"service_business_type",
],
)
}}
@ -18,10 +19,10 @@ select
cs.id_booking,
cs.service_name,
cs.active_accommodations_per_deal_segmentation,
cs.service_business_type,
-- Dimensions --
cs.id_deal,
cs.id_accommodation,
cs.service_business_type,
cs.new_dash_version,
cs.is_upgraded_service,
cs.main_billing_country_iso_3_per_deal,

View file

@ -6,6 +6,7 @@
"service_name",
"id_deal",
"active_accommodations_per_deal_segmentation",
"service_business_type",
],
)
}}
@ -17,6 +18,7 @@ select
cs.service_name,
cs.active_accommodations_per_deal_segmentation,
cs.id_deal,
cs.service_business_type,
-- Dimensions --
cs.new_dash_version,
cs.is_upgraded_service,
@ -29,4 +31,4 @@ left join
{{ ref("int_kpis__metric_daily_new_dash_created_services") }} cs
on date_trunc('week', cs.date)::date = d.first_day_week
where d.is_end_of_week = true and cs.id_deal is not null
group by 1, 2, 3, 4, 5, 6, 7, 8
group by 1, 2, 3, 4, 5, 6, 7, 8, 9

View file

@ -5393,6 +5393,7 @@ models:
- date,
- id_booking,
- service_name
- service_business_type
tests:
- dbt_utils.unique_combination_of_columns:
@ -5400,6 +5401,7 @@ models:
- date
- id_booking
- service_name
- service_business_type
columns:
- name: date
@ -5438,6 +5440,22 @@ models:
- "YES"
- "NO"
- name: service_business_type
data_type: string
description: |
Identifies the service type (Screening, Deposit Management, Protection)
according to New Pricing documentation.
Cannot be null.
tests:
- not_null
- accepted_values:
values:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "UNKNOWN"
- "UNSET"
- name: new_dash_version
data_type: string
description: |
@ -5488,7 +5506,8 @@ models:
- end_date,
- service_name,
- id_deal,
- active_accommodations_per_deal_segmentation.
- active_accommodations_per_deal_segmentation,
- service_business_type.
tests:
- dbt_utils.unique_combination_of_columns:
@ -5497,6 +5516,7 @@ models:
- service_name
- id_deal
- active_accommodations_per_deal_segmentation
- service_business_type
columns:
- name: start_date
@ -5525,6 +5545,22 @@ models:
tests:
- not_null
- name: service_business_type
data_type: string
description: |
Identifies the service type (Screening, Deposit Management, Protection)
according to New Pricing documentation.
Cannot be null.
tests:
- not_null
- accepted_values:
values:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "UNKNOWN"
- "UNSET"
- name: is_upgraded_service
data_type: string
description: |
@ -5595,7 +5631,8 @@ models:
- end_date,
- service_name,
- id_deal,
- active_accommodations_per_deal_segmentation.
- active_accommodations_per_deal_segmentation,
- service_business_type.
tests:
- dbt_utils.unique_combination_of_columns:
@ -5604,6 +5641,7 @@ models:
- service_name
- id_deal
- active_accommodations_per_deal_segmentation
- service_business_type
columns:
- name: start_date
@ -5632,6 +5670,22 @@ models:
tests:
- not_null
- name: service_business_type
data_type: string
description: |
Identifies the service type (Screening, Deposit Management, Protection)
according to New Pricing documentation.
Cannot be null.
tests:
- not_null
- accepted_values:
values:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "UNKNOWN"
- "UNSET"
- name: is_upgraded_service
data_type: string
description: |
@ -5733,6 +5787,7 @@ models:
- by_new_dash_version
- by_has_upgraded_service
- by_service
- by_service_business_type
- name: dimension_value
data_type: string
@ -5797,6 +5852,7 @@ models:
- by_new_dash_version
- by_has_upgraded_service
- by_service
- by_service_business_type
- name: dimension_value
data_type: string
@ -5854,6 +5910,7 @@ models:
- by_new_dash_version
- by_has_upgraded_service
- by_service
- by_service_business_type
- name: dimension_value
data_type: string
@ -5980,6 +6037,7 @@ models:
- date,
- id_booking,
- service_name
- service_business_type
tests:
- dbt_utils.unique_combination_of_columns:
@ -5987,6 +6045,7 @@ models:
- date
- id_booking
- service_name
- service_business_type
columns:
- name: date
@ -6044,6 +6103,7 @@ models:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "UNKNOWN"
- "UNSET"
- name: new_dash_version
@ -6104,6 +6164,7 @@ models:
- service_name,
- id_booking,
- active_accommodations_per_deal_segmentation.
- service_business_type
tests:
- dbt_utils.unique_combination_of_columns:
@ -6112,6 +6173,7 @@ models:
- id_booking
- service_name
- active_accommodations_per_deal_segmentation
- service_business_type
columns:
- name: start_date
@ -6177,6 +6239,7 @@ models:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "UNKNOWN"
- "UNSET"
- name: new_dash_version
@ -6236,7 +6299,8 @@ models:
- end_date,
- service_name,
- id_booking,
- active_accommodations_per_deal_segmentation.
- active_accommodations_per_deal_segmentation,
- service_business_type
tests:
- dbt_utils.unique_combination_of_columns:
@ -6245,6 +6309,7 @@ models:
- id_booking
- service_name
- active_accommodations_per_deal_segmentation
- service_business_type
columns:
- name: start_date
@ -6310,6 +6375,7 @@ models:
- "SCREENING"
- "PROTECTION"
- "DEPOSIT_MANAGEMENT"
- "UNKNOWN"
- "UNSET"
- name: new_dash_version