From 4654aad54caa7a20cf554798f5692c051c629327 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 14 Jan 2025 16:46:07 +0100 Subject: [PATCH 1/4] wip --- .../kpis/int_kpis__dimension_deals.sql | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/models/intermediate/kpis/int_kpis__dimension_deals.sql b/models/intermediate/kpis/int_kpis__dimension_deals.sql index f5586ef..71bc143 100644 --- a/models/intermediate/kpis/int_kpis__dimension_deals.sql +++ b/models/intermediate/kpis/int_kpis__dimension_deals.sql @@ -1,7 +1,24 @@ {{ config(materialized="table", unique_key="id_deal") }} with hubspot_deals as ( - select id_deal, deal_name as main_deal_name, live_date_utc as deal_start_date + select + id_deal, + deal_name as main_deal_name, + live_date_utc as deal_start_date, + date_trunc('month', live_date_utc) as deal_start_month, + cancellation_date_utc as deal_cancellation_date, + date_trunc('month', cancellation_date_utc) as deal_cancellation_month, + case + when amount_of_properties between 1 and 5 + then '01-05' + when amount_of_properties between 6 and 20 + then '06-20' + when amount_of_properties between 21 and 60 + then '21-60' + when amount_of_properties >= 61 + then '61+' + else 'UNSET' + end as hubspot_listing_segmentation from {{ ref("int_hubspot__deal") }} where live_date_utc is not null ), @@ -10,6 +27,7 @@ with id_deal, main_deal_name, first_created_date_utc as deal_start_date, + date_trunc('month', first_created_date_utc) as deal_start_month, main_billing_country_iso_3_per_deal from {{ ref("int_core__deal") }} ), @@ -39,7 +57,13 @@ with cd.main_billing_country_iso_3_per_deal, min( coalesce(hd.deal_start_date, cd.deal_start_date) - ) as effective_deal_start_date_utc + ) as effective_deal_start_date_utc, + min( + coalesce(hd.deal_start_month, cd.deal_start_month) + ) as effective_deal_start_month, + min(hd.deal_cancellation_date) as effective_deal_cancellation_date_utc, + min(hd.deal_cancellation_month) as effective_deal_cancellation_month, + min(hd.hubspot_listing_segmentation) as hubspot_listing_segmentation from hubspot_deals hd full outer join core_deals cd on hd.id_deal = cd.id_deal group by 1, 2, 3 @@ -52,6 +76,10 @@ select end as has_active_pms, ipd.distinct_active_pms as active_pms_list, cd.main_billing_country_iso_3_per_deal, - cd.effective_deal_start_date_utc + cd.effective_deal_start_date_utc, + cd.effective_deal_start_month, + cd.effective_deal_cancellation_date_utc, + cd.effective_deal_cancellation_month, + cd.hubspot_listing_segmentation from combined_deals cd left join integrations_per_deal ipd on cd.id_deal = ipd.id_deal From 1de5a6d33e4020e69987f0d1bd1bc9fe737d1dbe Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 14 Jan 2025 16:48:49 +0100 Subject: [PATCH 2/4] new field to int_kpis__dimension_deals --- models/intermediate/kpis/schema.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 380b26c..659dadb 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -475,6 +475,34 @@ models: host has been created according to Core. data_tests: - not_null + - name: effective_deal_start_month + data_type: date + description: | + Month of the starting date of the deal. + data_tests: + - not_null + - name: effective_deal_cancellation_date_utc + data_type: date + description: | + Effective date at which the deal cancelled it's partnership with Superhog. + - name: effective_deal_cancellation_month + data_type: date + description: | + Month of the cancellation date of the deal. + - name: hubspot_listing_segmentation + data_type: integer + description: | + Number of properties managed by the deal according + to what was set in HubSpot. + data_tests: + - accepted_values: + values: + - "0" + - "01-05" + - "06-20" + - "21-60" + - "61+" + - "UNSET" - name: int_kpis__dimension_daily_accommodation description: | From 42cea78b2cfaa97dd1bab4140b1fc1d118913612 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 14 Jan 2025 16:51:49 +0100 Subject: [PATCH 3/4] fixed test value --- models/intermediate/kpis/schema.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 659dadb..7b6ab4c 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -497,7 +497,6 @@ models: data_tests: - accepted_values: values: - - "0" - "01-05" - "06-20" - "21-60" From 32251fa5e9f9c2cdeccb264fcce9f362d2d14ed1 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 14 Jan 2025 17:25:59 +0100 Subject: [PATCH 4/4] addressed comments --- .../kpis/int_kpis__dimension_deals.sql | 8 ++++---- models/intermediate/kpis/schema.yml | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/models/intermediate/kpis/int_kpis__dimension_deals.sql b/models/intermediate/kpis/int_kpis__dimension_deals.sql index 71bc143..4794e95 100644 --- a/models/intermediate/kpis/int_kpis__dimension_deals.sql +++ b/models/intermediate/kpis/int_kpis__dimension_deals.sql @@ -61,8 +61,8 @@ with min( coalesce(hd.deal_start_month, cd.deal_start_month) ) as effective_deal_start_month, - min(hd.deal_cancellation_date) as effective_deal_cancellation_date_utc, - min(hd.deal_cancellation_month) as effective_deal_cancellation_month, + min(hd.deal_cancellation_date) as hubspot_deal_cancellation_date_utc, + min(hd.deal_cancellation_month) as hubspot_deal_cancellation_month, min(hd.hubspot_listing_segmentation) as hubspot_listing_segmentation from hubspot_deals hd full outer join core_deals cd on hd.id_deal = cd.id_deal @@ -78,8 +78,8 @@ select cd.main_billing_country_iso_3_per_deal, cd.effective_deal_start_date_utc, cd.effective_deal_start_month, - cd.effective_deal_cancellation_date_utc, - cd.effective_deal_cancellation_month, + cd.hubspot_deal_cancellation_date_utc, + cd.hubspot_deal_cancellation_month, cd.hubspot_listing_segmentation from combined_deals cd left join integrations_per_deal ipd on cd.id_deal = ipd.id_deal diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index 7b6ab4c..757f0cc 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -478,22 +478,26 @@ models: - name: effective_deal_start_month data_type: date description: | - Month of the starting date of the deal. + This field represents the first day of the month of the effective + start date of the deal. This is obtained by truncating the effective + deal start date to the month. data_tests: - not_null - - name: effective_deal_cancellation_date_utc + - name: hubspot_deal_cancellation_date_utc data_type: date description: | Effective date at which the deal cancelled it's partnership with Superhog. - - name: effective_deal_cancellation_month + - name: hubspot_deal_cancellation_month data_type: date description: | - Month of the cancellation date of the deal. + This field represents the first day of the month of the cancellation date + of the deal. This is obtained by truncating the cancellation deal date + to the month. - name: hubspot_listing_segmentation data_type: integer description: | - Number of properties managed by the deal according - to what was set in HubSpot. + Segment value based on the number of properties managed by the deal + according to what was set in HubSpot. data_tests: - accepted_values: values: