Adding protection names
This commit is contained in:
parent
c503d797b6
commit
9424a96707
1 changed files with 34 additions and 25 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
{{ config(materialized="table", unique_key="id_user_product_bundle") }}
|
{{ config(materialized="table", unique_key="id_user_product_bundle") }}
|
||||||
with
|
with
|
||||||
stg_core__user_product_bundle as (select * from {{ ref("stg_core__user_product_bundle") }}),
|
stg_core__user_product_bundle as (
|
||||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }}
|
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
|
select
|
||||||
upb.id_user_product_bundle,
|
upb.id_user_product_bundle,
|
||||||
|
|
@ -11,6 +13,8 @@ select
|
||||||
upb.id_protection_plan,
|
upb.id_protection_plan,
|
||||||
upb.product_bundle_name,
|
upb.product_bundle_name,
|
||||||
upb.product_bundle_display_name,
|
upb.product_bundle_display_name,
|
||||||
|
pp.protection_name,
|
||||||
|
pp.protection_display_name,
|
||||||
upb.display_on_front_end,
|
upb.display_on_front_end,
|
||||||
upb.chosen_product_services,
|
upb.chosen_product_services,
|
||||||
upb.starts_at_utc as original_starts_at_utc,
|
upb.starts_at_utc as original_starts_at_utc,
|
||||||
|
|
@ -22,9 +26,12 @@ select
|
||||||
the effective fields (start_date and end_date) rather than the
|
the effective fields (start_date and end_date) rather than the
|
||||||
backend ones (named as original_starts_at and original_ends_at).
|
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,
|
greatest(
|
||||||
|
date(upb.starts_at_utc), uh.lower_limit_migration_date_utc
|
||||||
|
) as effective_start_date_utc,
|
||||||
case
|
case
|
||||||
when upb.has_no_end_date then null
|
when upb.has_no_end_date
|
||||||
|
then null
|
||||||
else greatest(date(upb.ends_at_utc), uh.lower_limit_migration_date_utc)
|
else greatest(date(upb.ends_at_utc), uh.lower_limit_migration_date_utc)
|
||||||
end as effective_end_date_utc,
|
end as effective_end_date_utc,
|
||||||
upb.has_no_end_date,
|
upb.has_no_end_date,
|
||||||
|
|
@ -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
|
that product bundles need to be from users that have been
|
||||||
already migrated.
|
already migrated.
|
||||||
*/
|
*/
|
||||||
inner join int_core__user_host uh
|
inner join
|
||||||
|
int_core__user_host uh
|
||||||
on upb.id_user = uh.id_user_host
|
on upb.id_user = uh.id_user_host
|
||||||
and uh.is_user_migrated = True
|
and uh.is_user_migrated = true
|
||||||
|
left join stg_core__protection_plan pp on upb.id_protection_plan = pp.id_protection_plan
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue