Merged PR 4713: Adds a master table for guest products price plans
# Description Adds a master table for pricing regarding Guest Products in intermediate. I also added in staging a missing description for a field. This is a necessary step to work out the prices on guest products payments, which will come in a separated PR. # 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. - [ ] I've picked the right materialization for the affected models. **Left it as a view, let's adapt in the future if needed** # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #28513
This commit is contained in:
commit
dd9bb8a11b
3 changed files with 234 additions and 0 deletions
|
|
@ -0,0 +1,56 @@
|
||||||
|
with
|
||||||
|
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") }}),
|
||||||
|
price_plan_with_end_date 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,
|
||||||
|
lead(starts_at_utc) over (
|
||||||
|
partition by id_guest_product_configuration, id_currency
|
||||||
|
order by starts_at_utc desc
|
||||||
|
) as ends_at_utc
|
||||||
|
from stg_core__guest_product_configuration_price_plan
|
||||||
|
)
|
||||||
|
select
|
||||||
|
ppwed.id_guest_product_configuration_price_plan,
|
||||||
|
ppwed.id_guest_product_configuration,
|
||||||
|
icgp.guest_product_name,
|
||||||
|
icgp.guest_product_latest_display_name,
|
||||||
|
scgpc.configuration_level as configuration_level,
|
||||||
|
scgpc.id_user_host,
|
||||||
|
scc.iso4217_code as currency_code,
|
||||||
|
ppwed.product_price_in_local_currency,
|
||||||
|
ppwed.protection_limit_in_local_currency,
|
||||||
|
ppwed.starts_at_utc,
|
||||||
|
ppwed.start_date_utc,
|
||||||
|
coalesce(ppwed.ends_at_utc, {{ var("end_of_time") }}::timestamp) as ends_at_utc,
|
||||||
|
coalesce(date(ppwed.ends_at_utc), {{ var("end_of_time") }}) as end_date_utc,
|
||||||
|
case
|
||||||
|
when ppwed.ends_at_utc is null then true else false
|
||||||
|
end as is_latest_price_plan,
|
||||||
|
ppwed.created_at_utc,
|
||||||
|
ppwed.created_date_utc,
|
||||||
|
ppwed.updated_at_utc,
|
||||||
|
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
|
||||||
|
stg_core__guest_product_configuration scgpc
|
||||||
|
on ppwed.id_guest_product_configuration = scgpc.id_guest_product_configuration
|
||||||
|
left join
|
||||||
|
int_core__guest_products icgp on scgpc.id_guest_product = icgp.id_guest_product
|
||||||
|
|
@ -5914,3 +5914,173 @@ models:
|
||||||
description: |
|
description: |
|
||||||
Date of when the guest product display name started
|
Date of when the guest product display name started
|
||||||
to be in use. This is purely for information purposes.
|
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: id_guest_product_configuration
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
Identifier of the guest product configuration.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- 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: 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: 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: |
|
||||||
|
Date of when this configuration price plan starts.
|
||||||
|
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: |
|
||||||
|
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
|
- DEFAULT
|
||||||
- ACCOUNT
|
- 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
|
- name: created_at_utc
|
||||||
data_type: timestamp
|
data_type: timestamp
|
||||||
description: |
|
description: |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue