Merged PR 3090: Propagates Protection Plan to intermediate, for price and cover
# Description Propagates Protection Plan to price and cover to intermediate. Ideally I wanted to have a single table that contained prices + covers, but it is not straight forward to assume: * if a modification of the amount covered by a protection plan will create a new protection plan id, or not * if a modification of the price a protection costs will create a new protection plan id, or not So I keep it split for the time being. Besides, use cases might be different, ex: I want to see all prices of services (product + protection plan, but no need for cover). # 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. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #20809
This commit is contained in:
parent
bad27ecbc3
commit
ea8972a91b
3 changed files with 249 additions and 0 deletions
23
models/intermediate/core/int_core__protection_plan_cover.sql
Normal file
23
models/intermediate/core/int_core__protection_plan_cover.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
with
|
||||
stg_core__protection_plan_cover as (
|
||||
select * from {{ ref("stg_core__protection_plan_cover") }}
|
||||
),
|
||||
stg_core__protection_plan as (select * from {{ ref("stg_core__protection_plan") }}),
|
||||
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
||||
select
|
||||
ppc.id_protection_plan_cover,
|
||||
ppc.id_protection_plan,
|
||||
c.iso4217_code as currency_code,
|
||||
ppc.baseline_protection_cover_local_curr,
|
||||
ppc.lower_protection_cover_local_curr,
|
||||
ppc.maximum_protection_cover_local_curr,
|
||||
ppc.protection_plan_cover_name,
|
||||
pp.protection_name,
|
||||
ppc.created_at_utc,
|
||||
ppc.created_date_utc,
|
||||
ppc.updated_at_utc,
|
||||
ppc.updated_date_utc,
|
||||
ppc.dwh_extracted_at_utc
|
||||
from stg_core__protection_plan_cover ppc
|
||||
left join stg_core__protection_plan pp on ppc.id_protection_plan = pp.id_protection_plan
|
||||
left join stg_core__currency c on ppc.id_currency = c.id_currency
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
with
|
||||
stg_core__protection_plan_to_price as (
|
||||
select * from {{ ref("stg_core__protection_plan_to_price") }}
|
||||
),
|
||||
stg_core__protection_plan as (select * from {{ ref("stg_core__protection_plan") }}),
|
||||
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
||||
select
|
||||
pptp.id_protection_plan_to_price,
|
||||
pptp.id_protection_plan,
|
||||
pptp.payment_type,
|
||||
pptp.price_base_unit,
|
||||
pptp.invoicing_trigger,
|
||||
c.iso4217_code as currency_code,
|
||||
pptp.amount_local_curr,
|
||||
pptp.protection_plan_price_name,
|
||||
pp.protection_name,
|
||||
pptp.starts_at_utc,
|
||||
pptp.ends_at_utc,
|
||||
pptp.has_no_end_date,
|
||||
pptp.created_at_utc,
|
||||
pptp.created_date_utc,
|
||||
pptp.updated_at_utc,
|
||||
pptp.updated_date_utc,
|
||||
pptp.dwh_extracted_at_utc
|
||||
from stg_core__protection_plan_to_price pptp
|
||||
left join
|
||||
stg_core__protection_plan pp on pptp.id_protection_plan = pp.id_protection_plan
|
||||
left join stg_core__currency c on pptp.id_currency = c.id_currency
|
||||
|
|
@ -3618,3 +3618,201 @@ models:
|
|||
Timestamp of when this data was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_core__protection_plan_to_price
|
||||
description: |
|
||||
This model provides the information related to the prices of the different
|
||||
protection plans in the scope of New Pricing. It does not contain the amounts being
|
||||
protected, just how much it costs to purchase a given protection.
|
||||
Each protection plan can have prices in different currencies. Each price is
|
||||
storified and applies in the range of starts to end. If the end date is null,
|
||||
then the price is currently active.
|
||||
There is no possibility to allow custom pricing at user level.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: ends_at_utc
|
||||
column_B: starts_at_utc
|
||||
or_equal: True
|
||||
columns:
|
||||
- name: id_protection_plan_to_price
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the protection plan to price. Acts as the primary key for this table.
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- name: id_protection_plan
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the protection plan.
|
||||
tests:
|
||||
- not_null
|
||||
- name: payment_type
|
||||
data_type: string
|
||||
description: |
|
||||
Type of the payment, namely if the price represents a
|
||||
percentage or an amount.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "AMOUNT"
|
||||
- "PERCENTAGE"
|
||||
- name: price_base_unit
|
||||
data_type: string
|
||||
description: |
|
||||
Represents how the price value should be taken into account, either
|
||||
if the price is representing the total amount at booking level or
|
||||
it's a nightly fee.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "PER BOOKING"
|
||||
- "PER NIGHT"
|
||||
- name: invoicing_trigger
|
||||
data_type: string
|
||||
description: |
|
||||
Represents at which moment in time this service should be invoiced.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "PRE-BOOKING"
|
||||
- "POST-CHECKOUT"
|
||||
- "AT WAIVER PAYMENT"
|
||||
- "AT DEPOSIT PAYMENT"
|
||||
- "N/A"
|
||||
- name: currency_code
|
||||
data_type: string
|
||||
description:
|
||||
Currency iso4217 code. It identifies the currency for the amount stated in
|
||||
amount_local_curr.
|
||||
tests:
|
||||
- not_null
|
||||
- name: amount_local_curr
|
||||
data_type: decimal
|
||||
description: |
|
||||
Price amount of a given protection plan in the currency stated in id_currency.
|
||||
tests:
|
||||
- not_null
|
||||
- name: protection_plan_price_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name given to a protection plan to price, for example "ProtectionPlus Default Price".
|
||||
- name: pprotection_plan_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the protection plan, for example "ProtectionPlus".
|
||||
- name: starts_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this protection plan to price starts to be active.
|
||||
tests:
|
||||
- not_null
|
||||
- name: ends_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this protection plan to price ends to be active.
|
||||
It can be null, thus meaning it's currently active.
|
||||
- name: has_no_end_date
|
||||
data_type: boolean
|
||||
description: |
|
||||
True when ends_at_utc is not set, false otherwise.
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this protection plan to price was created.
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this protection plan to price was created.
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this protection plan to price was last updated.
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this protection plan to price was last updated.
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this data was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_core__protection_plan_cover
|
||||
description: |
|
||||
This model provides the information related to the cover, or amount protected,
|
||||
of the different protection plans in the scope of New Pricing.
|
||||
Each protection plan can have amounts protected in different currencies.
|
||||
There is no possibility to allow custom protection amounts at user level.
|
||||
|
||||
columns:
|
||||
- name: id_protection_plan_cover
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the protection plan cover. Acts as the primary key for this table.
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- name: id_protection_plan
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the protection plan.
|
||||
tests:
|
||||
- not_null
|
||||
- name: currency_code
|
||||
data_type: string
|
||||
description: Currency iso4217 code. It identifies the currency for the different protection covers.
|
||||
tests:
|
||||
- not_null
|
||||
- name: baseline_protection_cover_local_curr
|
||||
data_type: decimal
|
||||
description: |
|
||||
Baseline cover amount of a given protection plan in the currency stated in currency_code.
|
||||
tests:
|
||||
- not_null
|
||||
- name: lower_protection_cover_local_curr
|
||||
data_type: decimal
|
||||
description: |
|
||||
Lower cover amount of a given protection plan in the currency stated in currency_code.
|
||||
tests:
|
||||
- not_null
|
||||
- name: maximum_protection_cover_local_curr
|
||||
data_type: decimal
|
||||
description: |
|
||||
Maximum cover amount of a given protection plan in the currency stated in currency_code.
|
||||
tests:
|
||||
- not_null
|
||||
- name: protection_plan_cover_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name given to a protection plan cover, for example "Basic Protection £50K".
|
||||
- name: protection_plan_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name given to a protection plan, for example "Basic Protection".
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this protection plan cover was created.
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this protection plan cover was created.
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this protection plan cover was last updated.
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this protection plan cover was last updated.
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this data was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue