Adds end date
This commit is contained in:
parent
cba4b97082
commit
91e7fe09b1
2 changed files with 21 additions and 5 deletions
|
|
@ -21,7 +21,7 @@ with
|
|||
) as status_rank
|
||||
from stg_core__guest_product_configuration_status
|
||||
),
|
||||
ranked_price_plans as (
|
||||
price_plan_with_end_date as (
|
||||
select
|
||||
id_guest_product_configuration_price_plan,
|
||||
id_guest_product_configuration,
|
||||
|
|
@ -34,10 +34,10 @@ with
|
|||
created_date_utc,
|
||||
updated_at_utc,
|
||||
updated_date_utc,
|
||||
row_number() over (
|
||||
lead(starts_at_utc) over (
|
||||
partition by id_guest_product_configuration, id_currency
|
||||
order by starts_at_utc desc
|
||||
) as price_plan_rank
|
||||
) as ends_at_utc
|
||||
from stg_core__guest_product_configuration_price_plan
|
||||
)
|
||||
select
|
||||
|
|
@ -53,12 +53,14 @@ select
|
|||
rpp.protection_limit_in_local_currency,
|
||||
rpp.starts_at_utc,
|
||||
rpp.start_date_utc,
|
||||
case when rpp.price_plan_rank = 1 then true else false end as is_latest_price_plan,
|
||||
coalesce(rpp.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,
|
||||
case when rpp.ends_at_utc is null then true else false end as is_latest_price_plan,
|
||||
rpp.created_at_utc,
|
||||
rpp.created_date_utc,
|
||||
rpp.updated_at_utc,
|
||||
rpp.updated_date_utc
|
||||
from ranked_price_plans rpp
|
||||
from price_plan_with_end_date rpp
|
||||
left join stg_core__currency scc on rpp.id_currency = scc.id_currency
|
||||
left join
|
||||
stg_core__guest_product_configuration scgpc
|
||||
|
|
|
|||
|
|
@ -6040,6 +6040,13 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: ends_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this configuration price plan ends.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: start_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
|
|
@ -6047,6 +6054,13 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: end_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this configuration price plan ends.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_latest_price_plan
|
||||
data_type: boolean
|
||||
description: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue