Adds a master table for guest products price plans
This commit is contained in:
parent
b518c536f2
commit
cba4b97082
3 changed files with 249 additions and 0 deletions
|
|
@ -0,0 +1,71 @@
|
|||
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 (
|
||||
select * from {{ ref("stg_core__guest_product_configuration_price_plan") }}
|
||||
),
|
||||
stg_core__currency as (select * from {{ ref("stg_core__currency") }}),
|
||||
stg_core__guest_product_configuration as (
|
||||
select * from {{ ref("stg_core__guest_product_configuration") }}
|
||||
),
|
||||
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
|
||||
),
|
||||
ranked_price_plans as (
|
||||
select
|
||||
id_guest_product_configuration_price_plan,
|
||||
id_guest_product_configuration,
|
||||
id_currency,
|
||||
product_price_in_local_currency,
|
||||
protection_limit_in_local_currency,
|
||||
starts_at_utc,
|
||||
start_date_utc,
|
||||
created_at_utc,
|
||||
created_date_utc,
|
||||
updated_at_utc,
|
||||
updated_date_utc,
|
||||
row_number() over (
|
||||
partition by id_guest_product_configuration, id_currency
|
||||
order by starts_at_utc desc
|
||||
) as price_plan_rank
|
||||
from stg_core__guest_product_configuration_price_plan
|
||||
)
|
||||
select
|
||||
rpp.id_guest_product_configuration_price_plan,
|
||||
icgp.guest_product_name,
|
||||
icgp.guest_product_latest_display_name,
|
||||
scgpc.configuration_level as configuration_level,
|
||||
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,
|
||||
rpp.product_price_in_local_currency,
|
||||
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,
|
||||
rpp.created_at_utc,
|
||||
rpp.created_date_utc,
|
||||
rpp.updated_at_utc,
|
||||
rpp.updated_date_utc
|
||||
from ranked_price_plans rpp
|
||||
left join stg_core__currency scc on rpp.id_currency = scc.id_currency
|
||||
left join
|
||||
stg_core__guest_product_configuration scgpc
|
||||
on rpp.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
|
||||
int_core__guest_products icgp on scgpc.id_guest_product = icgp.id_guest_product
|
||||
|
|
@ -5914,3 +5914,173 @@ models:
|
|||
description: |
|
||||
Date of when the guest product display name started
|
||||
to be in use. This is purely for information purposes.
|
||||
|
||||
- name: int_core__guest_product_price_plans
|
||||
description: |
|
||||
Master table of Pricing for Guest Products.
|
||||
Contains the information of the guest product, whether if it corresponds
|
||||
to a default pricing or a custom pricing for a given host and
|
||||
whether the product itself is currently available and if it is available
|
||||
for Guest Journey purposes or not. For each case, a specific product price
|
||||
and protection limit is displayed for all working currencies.
|
||||
Historical price plans are also reflected here, so keep this in mind
|
||||
when querying this model.
|
||||
|
||||
columns:
|
||||
- name: id_guest_product_configuration_price_plan
|
||||
data_type: bigint
|
||||
description: |
|
||||
Unique identifier of the guest product configuration price plan.
|
||||
Acts as the primary key for this table.
|
||||
data_tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: guest_product_name
|
||||
data_type: character varying
|
||||
description: |
|
||||
Internal name of the guest product. This is the
|
||||
name used in internal configurations within our
|
||||
systems. Only a single guest product name can exist
|
||||
for a given product, opposite to the guest product display
|
||||
name.
|
||||
Recommended for building dedicated guest product logic.
|
||||
It cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: guest_product_latest_display_name
|
||||
data_type: character varying
|
||||
description: |
|
||||
Latest display name of the guest product. This is the
|
||||
commercial or client-facing name.
|
||||
If multiple commercial names exist for a given guest
|
||||
product, then only the last one is available.
|
||||
Recommended for reporting purposes.
|
||||
It cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: configuration_level
|
||||
data_type: string
|
||||
description: |
|
||||
Level of the configuration. It can correspond to
|
||||
an account-based configuration (custom) or the
|
||||
default configuration.
|
||||
It cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- DEFAULT
|
||||
- ACCOUNT
|
||||
|
||||
- name: id_user_host
|
||||
data_type: text
|
||||
description: |
|
||||
Id of the user that acts as Host.
|
||||
This field can be null if the configuration is the
|
||||
default configuration. If it's set, it means this
|
||||
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
|
||||
data_type: text
|
||||
description:
|
||||
Currency iso4217 code. It identifies the currency for the amount stated in
|
||||
product_price_in_local_currency and protection_limit_in_local_currency.
|
||||
It cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: product_price_in_local_currency
|
||||
data_type: numeric
|
||||
description: |
|
||||
Price of the guest product in local currency.
|
||||
data_tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
|
||||
- name: protection_limit_in_local_currency
|
||||
data_type: numeric
|
||||
description: |
|
||||
Protection limit in local currency, or covered amount.
|
||||
data_tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
|
||||
- name: starts_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this configuration price plan starts.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: start_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this configuration price plan starts.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: is_latest_price_plan
|
||||
data_type: boolean
|
||||
description: |
|
||||
If true, it means this is the latest price plan for a given
|
||||
configuration. If false, then this is an historical price plan
|
||||
that has been overriden with a new plan.
|
||||
It cannot be null.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this record was created.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this record was created.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this record was last updated.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this record was last updated.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
|
|
|||
|
|
@ -2035,6 +2035,14 @@ models:
|
|||
- DEFAULT
|
||||
- ACCOUNT
|
||||
|
||||
- name: id_user_host
|
||||
data_type: character varying
|
||||
description: |
|
||||
Id of the user that acts as Host.
|
||||
This field can be null if the configuration is the
|
||||
default configuration. If it's set, it means this
|
||||
configuration is a custom configuration.
|
||||
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue