Addressed comments
This commit is contained in:
parent
1ebd1c5ccb
commit
721f3e4e9e
4 changed files with 95 additions and 86 deletions
|
|
@ -2,24 +2,24 @@
|
|||
config(
|
||||
materialized="table",
|
||||
unique_key=[
|
||||
"id_user_host",
|
||||
"id_user_product_bundle",
|
||||
"service_name",
|
||||
"date",
|
||||
"id_user_host",
|
||||
"product_bundle_name",
|
||||
"service_name",
|
||||
"service_business_type",
|
||||
],
|
||||
)
|
||||
}}
|
||||
select
|
||||
-- Unique Key --
|
||||
d.date_day as date,
|
||||
dd.date,
|
||||
bs.id_user_host,
|
||||
bs.id_user_product_bundle,
|
||||
bs.product_service_display_name as service_name,
|
||||
coalesce(ps.service_business_type, 'UNSET') as service_business_type,
|
||||
bs.product_bundle_name,
|
||||
bs.product_display_name as service_name,
|
||||
bs.service_business_type,
|
||||
-- Dimensions --
|
||||
coalesce(uh.id_deal, 'UNSET') as id_deal,
|
||||
case when ps.is_default_service then 'NO' else 'YES' end as is_upgraded_service,
|
||||
case when bs.is_default_service then 'NO' else 'YES' end as is_upgraded_service,
|
||||
coalesce(uh.new_dash_version, 'UNSET') as new_dash_version,
|
||||
coalesce(
|
||||
uh.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||
|
|
@ -27,66 +27,14 @@ select
|
|||
coalesce(
|
||||
icmas.active_accommodations_per_deal_segmentation, 'UNSET'
|
||||
) as active_accommodations_per_deal_segmentation
|
||||
from {{ ref("int_dates") }} as d
|
||||
from {{ ref("int_kpis__dimension_dates") }} as dd
|
||||
inner join
|
||||
{{ ref("int_core__user_host") }} as uh
|
||||
on uh.is_user_in_new_dash = true
|
||||
and uh.is_missing_id_deal = false
|
||||
and uh.is_test_account = false
|
||||
and d.date_day between uh.user_in_new_dash_since_date_utc and current_date - 1
|
||||
on dd.date >= uh.user_in_new_dash_since_date_utc
|
||||
inner join
|
||||
{{ ref("int_core__user_product_bundle_contains_services") }} as bs
|
||||
on uh.id_user_host = bs.id_user_host
|
||||
left join
|
||||
{{ ref("stg_core__product_service") }} as ps
|
||||
on ps.product_service_display_name = bs.product_service_display_name
|
||||
left join
|
||||
{{ ref("int_hubspot__deal") }} as hd
|
||||
on uh.id_deal = hd.id_deal
|
||||
and coalesce(hd.cancellation_date_utc, {{ var("end_of_time") }}) >= d.date_day
|
||||
left join
|
||||
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
||||
on uh.id_deal = icmas.id_deal
|
||||
and d.date_day = icmas.date
|
||||
-- Union of all product services with all protection plan services.
|
||||
-- This is because there are basically two types of services: product services
|
||||
-- and protection plan services and they are stored in different tables.
|
||||
union all
|
||||
select
|
||||
-- Unique Key --
|
||||
d.date_day as date,
|
||||
pb.id_user_host,
|
||||
pb.id_user_product_bundle,
|
||||
coalesce(pb.protection_display_name, {{ var("default_service") }}) as service_name,
|
||||
'PROTECTION' as service_business_type,
|
||||
-- Dimensions --
|
||||
coalesce(uh.id_deal, 'UNSET') as id_deal,
|
||||
case when pp.is_default_service then 'NO' else 'YES' end as is_upgraded_service,
|
||||
coalesce(uh.new_dash_version, 'UNSET') as new_dash_version,
|
||||
coalesce(
|
||||
uh.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||
) as main_billing_country_iso_3_per_deal,
|
||||
coalesce(
|
||||
icmas.active_accommodations_per_deal_segmentation, 'UNSET'
|
||||
) as active_accommodations_per_deal_segmentation
|
||||
from {{ ref("int_dates") }} as d
|
||||
inner join
|
||||
{{ ref("int_core__user_host") }} as uh
|
||||
on uh.is_user_in_new_dash = true
|
||||
and uh.is_missing_id_deal = false
|
||||
and uh.is_test_account = false
|
||||
and d.date_day between uh.user_in_new_dash_since_date_utc and current_date - 1
|
||||
inner join
|
||||
{{ ref("int_core__user_product_bundle") }} as pb
|
||||
on uh.id_user_host = pb.id_user_host
|
||||
left join
|
||||
{{ ref("stg_core__protection_plan") }} as pp
|
||||
on pp.protection_display_name = pb.protection_display_name
|
||||
left join
|
||||
{{ ref("int_hubspot__deal") }} as hd
|
||||
on uh.id_deal = hd.id_deal
|
||||
and coalesce(hd.cancellation_date_utc, {{ var("end_of_time") }}) >= d.date_day
|
||||
left join
|
||||
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
||||
on uh.id_deal = icmas.id_deal
|
||||
and d.date_day = icmas.date
|
||||
and dd.date = icmas.date
|
||||
|
|
|
|||
|
|
@ -7393,7 +7393,7 @@ models:
|
|||
in this case:
|
||||
- date,
|
||||
- id_user_host,
|
||||
- id_user_product_bundle,
|
||||
- product_bundle_name,
|
||||
- service_name,
|
||||
- service_business_type
|
||||
|
||||
|
|
@ -7419,9 +7419,9 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_user_product_bundle
|
||||
data_type: bigint
|
||||
description: Unique identifier of the User Product Bundle.
|
||||
- name: product_bundle_name
|
||||
data_type: string
|
||||
description: Name of the product bundle.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
|
|
@ -7496,8 +7496,3 @@ models:
|
|||
Main billing country of the host aggregated at Deal level.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: created_services
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily services created in a given date and per specified dimension.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue