Merged PR 3084: Provide Protection Name in User Product Bundle
# Description Small PR to provide the Protection Name into User Product Bundle There's some additional automatic formatting changes # 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. - [X] I have checked for DRY opportunities with other models and docs. - [X] 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: #20809
This commit is contained in:
commit
9dc1b4b99f
2 changed files with 44 additions and 25 deletions
|
|
@ -1,18 +1,22 @@
|
|||
{{ config(materialized="table", unique_key="id_user_product_bundle") }}
|
||||
with
|
||||
stg_core__user_product_bundle as (select * from {{ ref("stg_core__user_product_bundle") }}),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }}
|
||||
)
|
||||
stg_core__user_product_bundle as (
|
||||
select * from {{ ref("stg_core__user_product_bundle") }}
|
||||
),
|
||||
stg_core__protection_plan as (select * from {{ ref("stg_core__protection_plan") }}),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }})
|
||||
|
||||
select
|
||||
upb.id_user_product_bundle,
|
||||
upb.id_user as id_user_host,
|
||||
upb.id_product_bundle,
|
||||
upb.id_protection_plan,
|
||||
upb.product_bundle_name,
|
||||
upb.product_bundle_display_name,
|
||||
upb.display_on_front_end,
|
||||
upb.chosen_product_services,
|
||||
upb.id_user_product_bundle,
|
||||
upb.id_user as id_user_host,
|
||||
upb.id_product_bundle,
|
||||
upb.id_protection_plan,
|
||||
upb.product_bundle_name,
|
||||
upb.product_bundle_display_name,
|
||||
pp.protection_name,
|
||||
pp.protection_display_name,
|
||||
upb.display_on_front_end,
|
||||
upb.chosen_product_services,
|
||||
upb.starts_at_utc as original_starts_at_utc,
|
||||
upb.ends_at_utc as original_ends_at_utc,
|
||||
/*
|
||||
|
|
@ -22,18 +26,21 @@ select
|
|||
the effective fields (start_date and end_date) rather than the
|
||||
backend ones (named as original_starts_at and original_ends_at).
|
||||
*/
|
||||
greatest(date(upb.starts_at_utc), uh.lower_limit_migration_date_utc) as effective_start_date_utc,
|
||||
case
|
||||
when upb.has_no_end_date then null
|
||||
else greatest(date(upb.ends_at_utc), uh.lower_limit_migration_date_utc)
|
||||
greatest(
|
||||
date(upb.starts_at_utc), uh.lower_limit_migration_date_utc
|
||||
) as effective_start_date_utc,
|
||||
case
|
||||
when upb.has_no_end_date
|
||||
then null
|
||||
else greatest(date(upb.ends_at_utc), uh.lower_limit_migration_date_utc)
|
||||
end as effective_end_date_utc,
|
||||
upb.has_no_end_date,
|
||||
upb.created_at_utc,
|
||||
upb.created_date_utc,
|
||||
upb.updated_at_utc,
|
||||
upb.updated_date_utc,
|
||||
upb.dwh_extracted_at
|
||||
from stg_core__user_product_bundle upb
|
||||
upb.has_no_end_date,
|
||||
upb.created_at_utc,
|
||||
upb.created_date_utc,
|
||||
upb.updated_at_utc,
|
||||
upb.updated_date_utc,
|
||||
upb.dwh_extracted_at
|
||||
from stg_core__user_product_bundle upb
|
||||
/*
|
||||
There are many not migrated users that have product bundles.
|
||||
Since users are not migrated, these bundles cannot be active.
|
||||
|
|
@ -41,6 +48,8 @@ In order to avoid potential upstream problems, it is enforced
|
|||
that product bundles need to be from users that have been
|
||||
already migrated.
|
||||
*/
|
||||
inner join int_core__user_host uh
|
||||
on upb.id_user = uh.id_user_host
|
||||
and uh.is_user_migrated = True
|
||||
inner join
|
||||
int_core__user_host uh
|
||||
on upb.id_user = uh.id_user_host
|
||||
and uh.is_user_migrated = true
|
||||
left join stg_core__protection_plan pp on upb.id_protection_plan = pp.id_protection_plan
|
||||
|
|
|
|||
|
|
@ -2675,6 +2675,16 @@ models:
|
|||
description: |
|
||||
The name of the Product Bundle, better fit for visualisations.
|
||||
|
||||
- name: protection_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the Protection Plan associated to the Product Bundle.
|
||||
|
||||
- name: protection_display_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the Protection Plan, better fit for visualisations.
|
||||
|
||||
- name: display_on_front_end
|
||||
data_type: boolean
|
||||
description: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue