Removes configuration status and adds config id for further joins
This commit is contained in:
parent
91e7fe09b1
commit
74a76fe8fc
2 changed files with 25 additions and 56 deletions
|
|
@ -1,7 +1,4 @@
|
||||||
with
|
with
|
||||||
stg_core__guest_product_configuration_status as (
|
|
||||||
select * from {{ ref("stg_core__guest_product_configuration_status") }}
|
|
||||||
),
|
|
||||||
stg_core__guest_product_configuration_price_plan as (
|
stg_core__guest_product_configuration_price_plan as (
|
||||||
select * from {{ ref("stg_core__guest_product_configuration_price_plan") }}
|
select * from {{ ref("stg_core__guest_product_configuration_price_plan") }}
|
||||||
),
|
),
|
||||||
|
|
@ -10,17 +7,6 @@ with
|
||||||
select * from {{ ref("stg_core__guest_product_configuration") }}
|
select * from {{ ref("stg_core__guest_product_configuration") }}
|
||||||
),
|
),
|
||||||
int_core__guest_products as (select * from {{ ref("int_core__guest_products") }}),
|
int_core__guest_products as (select * from {{ ref("int_core__guest_products") }}),
|
||||||
ranked_configuration_status as (
|
|
||||||
select
|
|
||||||
id_guest_product_configuration,
|
|
||||||
is_enabled,
|
|
||||||
is_enabled_for_guest_journey,
|
|
||||||
starts_at_utc,
|
|
||||||
row_number() over (
|
|
||||||
partition by id_guest_product_configuration order by starts_at_utc desc
|
|
||||||
) as status_rank
|
|
||||||
from stg_core__guest_product_configuration_status
|
|
||||||
),
|
|
||||||
price_plan_with_end_date as (
|
price_plan_with_end_date as (
|
||||||
select
|
select
|
||||||
id_guest_product_configuration_price_plan,
|
id_guest_product_configuration_price_plan,
|
||||||
|
|
@ -41,33 +27,30 @@ with
|
||||||
from stg_core__guest_product_configuration_price_plan
|
from stg_core__guest_product_configuration_price_plan
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
rpp.id_guest_product_configuration_price_plan,
|
ppwed.id_guest_product_configuration_price_plan,
|
||||||
|
ppwed.id_guest_product_configuration,
|
||||||
icgp.guest_product_name,
|
icgp.guest_product_name,
|
||||||
icgp.guest_product_latest_display_name,
|
icgp.guest_product_latest_display_name,
|
||||||
scgpc.configuration_level as configuration_level,
|
scgpc.configuration_level as configuration_level,
|
||||||
scgpc.id_user_host,
|
scgpc.id_user_host,
|
||||||
rks.is_enabled as is_currently_enabled,
|
|
||||||
rks.is_enabled_for_guest_journey as is_currently_enabled_for_guest_journey,
|
|
||||||
scc.iso4217_code as currency_code,
|
scc.iso4217_code as currency_code,
|
||||||
rpp.product_price_in_local_currency,
|
ppwed.product_price_in_local_currency,
|
||||||
rpp.protection_limit_in_local_currency,
|
ppwed.protection_limit_in_local_currency,
|
||||||
rpp.starts_at_utc,
|
ppwed.starts_at_utc,
|
||||||
rpp.start_date_utc,
|
ppwed.start_date_utc,
|
||||||
coalesce(rpp.ends_at_utc, {{ var("end_of_time") }}::timestamp) as ends_at_utc,
|
coalesce(ppwed.ends_at_utc, {{ var("end_of_time") }}::timestamp) as ends_at_utc,
|
||||||
coalesce(date(rpp.ends_at_utc), {{ var("end_of_time") }}) as end_date_utc,
|
coalesce(date(ppwed.ends_at_utc), {{ var("end_of_time") }}) as end_date_utc,
|
||||||
case when rpp.ends_at_utc is null then true else false end as is_latest_price_plan,
|
case
|
||||||
rpp.created_at_utc,
|
when ppwed.ends_at_utc is null then true else false
|
||||||
rpp.created_date_utc,
|
end as is_latest_price_plan,
|
||||||
rpp.updated_at_utc,
|
ppwed.created_at_utc,
|
||||||
rpp.updated_date_utc
|
ppwed.created_date_utc,
|
||||||
from price_plan_with_end_date rpp
|
ppwed.updated_at_utc,
|
||||||
left join stg_core__currency scc on rpp.id_currency = scc.id_currency
|
ppwed.updated_date_utc
|
||||||
|
from price_plan_with_end_date ppwed
|
||||||
|
left join stg_core__currency scc on ppwed.id_currency = scc.id_currency
|
||||||
left join
|
left join
|
||||||
stg_core__guest_product_configuration scgpc
|
stg_core__guest_product_configuration scgpc
|
||||||
on rpp.id_guest_product_configuration = scgpc.id_guest_product_configuration
|
on ppwed.id_guest_product_configuration = scgpc.id_guest_product_configuration
|
||||||
left join
|
|
||||||
ranked_configuration_status rks
|
|
||||||
on scgpc.id_guest_product_configuration = rks.id_guest_product_configuration
|
|
||||||
and rks.status_rank = 1 -- Get only latest status
|
|
||||||
left join
|
left join
|
||||||
int_core__guest_products icgp on scgpc.id_guest_product = icgp.id_guest_product
|
int_core__guest_products icgp on scgpc.id_guest_product = icgp.id_guest_product
|
||||||
|
|
|
||||||
|
|
@ -5936,6 +5936,13 @@ models:
|
||||||
- not_null
|
- not_null
|
||||||
- unique
|
- unique
|
||||||
|
|
||||||
|
- name: id_guest_product_configuration
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
Identifier of the guest product configuration.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
- name: guest_product_name
|
- name: guest_product_name
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
description: |
|
description: |
|
||||||
|
|
@ -5983,27 +5990,6 @@ models:
|
||||||
default configuration. If it's set, it means this
|
default configuration. If it's set, it means this
|
||||||
configuration is a custom configuration.
|
configuration is a custom configuration.
|
||||||
|
|
||||||
- name: is_currently_enabled
|
|
||||||
data_type: boolean
|
|
||||||
description: |
|
|
||||||
Indicates if the product is currently enabled or not.
|
|
||||||
- If true, then the product is visible everywhere.
|
|
||||||
- If false, then the product is disabled. Therefore,
|
|
||||||
the product is NOT visible anywhere.
|
|
||||||
It cannot be null.
|
|
||||||
data_tests:
|
|
||||||
- not_null
|
|
||||||
|
|
||||||
- name: is_currently_enabled_for_guest_journey
|
|
||||||
data_type: boolean
|
|
||||||
description: |
|
|
||||||
Indicates if the product, for a given user, is currently
|
|
||||||
enabled for the guest journey.
|
|
||||||
- If true, then the product is visible in the guest journey.
|
|
||||||
It cannot be null.
|
|
||||||
data_tests:
|
|
||||||
- not_null
|
|
||||||
|
|
||||||
- name: currency_code
|
- name: currency_code
|
||||||
data_type: text
|
data_type: text
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue