Addressed comments
This commit is contained in:
parent
1ebd1c5ccb
commit
721f3e4e9e
4 changed files with 95 additions and 86 deletions
|
|
@ -3,18 +3,50 @@ with
|
|||
stg_core__user_product_bundle as (
|
||||
select * from {{ ref("stg_core__user_product_bundle") }}
|
||||
),
|
||||
stg_core__product_service as (select * from {{ ref("stg_core__product_service") }})
|
||||
stg_core__product_service as (select * from {{ ref("stg_core__product_service") }}),
|
||||
stg_core__protection_plan as (select * from {{ ref("stg_core__protection_plan") }}),
|
||||
int_core__user_host as (
|
||||
select *
|
||||
from {{ ref("int_core__user_host") }}
|
||||
where
|
||||
is_user_in_new_dash = true
|
||||
and is_missing_id_deal = false
|
||||
and is_test_account = false
|
||||
)
|
||||
|
||||
select
|
||||
pb.id_user_product_bundle,
|
||||
pb.id_user as id_user_host,
|
||||
pb.id_product_bundle,
|
||||
ps.id_product_service,
|
||||
ps.id_product_service as id_product,
|
||||
'SERVICE' as product_type,
|
||||
pb.product_bundle_name,
|
||||
ps.product_service_name,
|
||||
ps.product_service_display_name
|
||||
ps.service_business_type,
|
||||
ps.is_default_service,
|
||||
ps.product_service_name as product_name,
|
||||
ps.product_service_display_name as product_display_name
|
||||
from stg_core__user_product_bundle pb
|
||||
inner join int_core__user_host uh on pb.id_user = uh.id_user_host
|
||||
cross join stg_core__product_service ps
|
||||
where
|
||||
-- bitwise AND (&) operator to determine if a specific service is part of the bundle
|
||||
pb.chosen_product_services & ps.product_service_binary_tier > 0
|
||||
union all
|
||||
select
|
||||
pb.id_user_product_bundle,
|
||||
pb.id_user as id_user_host,
|
||||
pb.id_product_bundle,
|
||||
coalesce(pb.id_protection_plan, 1) as id_product,
|
||||
'PROTECTION' as product_type,
|
||||
pb.product_bundle_name,
|
||||
'PROTECTION' as service_business_type,
|
||||
pp.is_default_service,
|
||||
coalesce(pp.protection_name, {{ var("default_service") }}) as product_name,
|
||||
coalesce(
|
||||
pp.protection_display_name, {{ var("default_service") }}
|
||||
) as product_display_name
|
||||
from stg_core__user_product_bundle pb
|
||||
inner join int_core__user_host uh on pb.id_user = uh.id_user_host
|
||||
left join
|
||||
stg_core__protection_plan pp
|
||||
on coalesce(pb.id_protection_plan, 1) = pp.id_protection_plan
|
||||
|
|
|
|||
|
|
@ -3018,15 +3018,17 @@ models:
|
|||
- name: int_core__user_product_bundle_contains_services
|
||||
description: |
|
||||
This table contains the information of "this user has a certain product bundle which
|
||||
contains these services."
|
||||
It's a denormalised relationship to break the power of 2 link between chosen_product_services
|
||||
and product_service_binary_tier, which allows standard joins using the ids.
|
||||
contains these services and protections."
|
||||
It's a denormalised relationship to break the power of 2 link between
|
||||
chosen_product_services/protection and product_binary_tier,
|
||||
which allows standard joins using the ids.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- id_user_product_bundle
|
||||
- id_product_service
|
||||
- id_product
|
||||
- product_type
|
||||
|
||||
columns:
|
||||
- name: id_user_product_bundle
|
||||
|
|
@ -3049,13 +3051,24 @@ models:
|
|||
description: |
|
||||
The identifier of the product bundle. Can be null if it's a custom bundle.
|
||||
|
||||
- name: id_product_service
|
||||
- name: id_product
|
||||
data_type: bigint
|
||||
description: |
|
||||
The identifier of the product service.
|
||||
The identifier of the product.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: product_type
|
||||
data_type: string
|
||||
description: |
|
||||
The type of the product, which can be either "service" or "protection".
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "SERVICE"
|
||||
- "PROTECTION"
|
||||
|
||||
- name: product_bundle_name
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
@ -3063,17 +3076,38 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: product_service_name
|
||||
- name: service_business_type
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the product service.
|
||||
Identifies the service type (Screening, Deposit Management, Protection
|
||||
or Guest Agreement) according to New Pricing documentation.
|
||||
Cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- SCREENING
|
||||
- DEPOSIT_MANAGEMENT
|
||||
- GUEST_AGREEMENT
|
||||
- PROTECTION
|
||||
|
||||
- name: is_default_service
|
||||
data_type: boolean
|
||||
description: |
|
||||
Flag that determines if the service is a default one (True)
|
||||
or an upgraded service (False).
|
||||
|
||||
- name: product_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the product service or protection.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: product_service_display_name
|
||||
- name: product_display_name
|
||||
data_type: string
|
||||
description: |
|
||||
The display name of the product service.
|
||||
The display name of the product service or protection.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue