Merged PR 3872: Staging model for all screen & protect price tables
# Description Staging model for all screen & protect price tables. There are 4 types of protections for screen & protect and each of them have their own prices # 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. # Other - [ ] Check if a full-refresh is required after this PR is merged. Staging model for all screen & protect price tables Related work items: #25360
This commit is contained in:
commit
6fd9c16e59
6 changed files with 453 additions and 0 deletions
|
|
@ -267,3 +267,11 @@ sources:
|
|||
identifier: ApimUser
|
||||
- name: ApimUserType
|
||||
identifier: ApimUserType
|
||||
- name: BasicProtection
|
||||
identifier: BasicProtection
|
||||
- name: DamageWaiver
|
||||
identifier: DamageWaiver
|
||||
- name: ScreenAndProtect
|
||||
identifier: ScreenAndProtect
|
||||
- name: StandaloneProtection
|
||||
identifier: StandaloneProtection
|
||||
|
|
|
|||
|
|
@ -1443,3 +1443,363 @@ models:
|
|||
Timestamp of when this record was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: stg_core__basic_protection
|
||||
description: "Contains the basic protection fees and protection amounts
|
||||
for different protection options and currencies."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: end_at_utc
|
||||
column_B: start_at_utc
|
||||
or_equal: True
|
||||
columns:
|
||||
- name: id_basic_protection
|
||||
data_type: bigint
|
||||
description: "Unique identifier of the basic protection.
|
||||
Acts as the primary key for this table."
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: long_stay_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for long stay bookings.
|
||||
Bookings of more than 30 days are considered long."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: short_stay_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for short stay bookings"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: id_currency
|
||||
data_type: bigint
|
||||
description: "Id of the currency, works as a foreign key to the
|
||||
currency table"
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: protection_basic_amount_in_local_currency
|
||||
data_type: bigint
|
||||
description: "Amount in local currency of basic protection coverage"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000000
|
||||
strictly: true
|
||||
|
||||
- name: start_at_utc
|
||||
data_type: timestamp
|
||||
description: "Timestamp of when this basic protection record is active"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: start_date_utc
|
||||
data_type: date
|
||||
description: "Date of when this basic protection record is active"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: end_at_utc
|
||||
data_type: timestamp
|
||||
description:
|
||||
"Timestamp of when this basic protection record is no longer active.
|
||||
It can be null."
|
||||
|
||||
- name: end_date_utc
|
||||
data_type: date
|
||||
description:
|
||||
"Date of when this basic protection record is no longer active.
|
||||
It can be null."
|
||||
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this record was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: stg_core__damage_waiver
|
||||
description: "Contains the damage waiver fees and protection amounts
|
||||
for different protection options and currencies."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: end_at_utc
|
||||
column_B: start_at_utc
|
||||
or_equal: True
|
||||
columns:
|
||||
- name: id_damage_waiver
|
||||
data_type: bigint
|
||||
description: "Unique identifier of the damage waiver.
|
||||
Acts as the primary key for this table."
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: booking_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for bookings"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: id_currency
|
||||
data_type: bigint
|
||||
description: "Id of the currency, works as a foreign key to the
|
||||
currency table"
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: protection_basic_amount_in_local_currency
|
||||
data_type: bigint
|
||||
description: "Amount in local currency of basic protection coverage"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000000
|
||||
strictly: true
|
||||
|
||||
- name: start_at_utc
|
||||
data_type: timestamp
|
||||
description: "Timestamp of when this basic protection record is active"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: start_date_utc
|
||||
data_type: date
|
||||
description: "Date of when this basic protection record is active"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: end_at_utc
|
||||
data_type: timestamp
|
||||
description:
|
||||
"Timestamp of when this basic protection record is no longer active.
|
||||
It can be null."
|
||||
|
||||
- name: end_date_utc
|
||||
data_type: date
|
||||
description:
|
||||
"Date of when this basic protection record is no longer active.
|
||||
It can be null."
|
||||
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this record was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: stg_core__screen_and_protect
|
||||
description: "Contains the screen and protect fees and protection amounts
|
||||
for different protection options and currencies."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: end_at_utc
|
||||
column_B: start_at_utc
|
||||
or_equal: True
|
||||
columns:
|
||||
- name: id_screen_and_protect
|
||||
data_type: bigint
|
||||
description: "Unique identifier of the Screen and Protect record.
|
||||
Acts as the primary key for this table."
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: long_stay_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for long stay bookings.
|
||||
Bookings of more than 30 days are considered long."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: short_stay_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for short stay bookings."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: id_currency
|
||||
data_type: bigint
|
||||
description: "Id of the currency, works as a foreign key
|
||||
to the currency table."
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: protection_basic_amount_in_local_currency
|
||||
data_type: bigint
|
||||
description: "Amount in local currency of basic protection coverage."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000000
|
||||
strictly: true
|
||||
|
||||
- name: protection_extended_amount_in_local_currency
|
||||
data_type: bigint
|
||||
description: "Amount in local currency of extended protection coverage."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 100000000
|
||||
strictly: true
|
||||
|
||||
- name: start_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp when this Screen and Protect record becomes active."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: start_date_utc
|
||||
data_type: date
|
||||
description: "Date when this Screen and Protect record becomes active."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: end_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp when this Screen and Protect record is no
|
||||
longer active. It can be null."
|
||||
|
||||
- name: end_date_utc
|
||||
data_type: date
|
||||
description: "Date when this Screen and Protect record is no
|
||||
longer active. It can be null."
|
||||
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: |
|
||||
Timestamp of when this record was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: stg_core__standalone_protection
|
||||
description: "Contains the standalone protection fees and protection amounts
|
||||
for different protection options and currencies."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_pair_values_A_to_be_greater_than_B:
|
||||
column_A: end_at_utc
|
||||
column_B: start_at_utc
|
||||
or_equal: True
|
||||
columns:
|
||||
- name: id_standalone_protection
|
||||
data_type: bigint
|
||||
description: "Unique identifier for the standalone protection record.
|
||||
Acts as the primary key for this table."
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: long_stay_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for long stay bookings.
|
||||
Bookings of more than 30 days are considered long."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: short_stay_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for short stay bookings."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: id_currency
|
||||
data_type: bigint
|
||||
description: "Id of the currency, works as a foreign key
|
||||
to the currency table."
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: protection_starting_amount_in_local_currency
|
||||
data_type: bigint
|
||||
description: "Starting amount in local currency of protection coverage."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000000
|
||||
strictly: true
|
||||
|
||||
- name: protection_extended_amount_in_local_currency
|
||||
data_type: bigint
|
||||
description: "Extended amount in local currency of protection coverage."
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 100000000
|
||||
strictly: true
|
||||
|
||||
- name: start_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp when this standalone protection record becomes active."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: start_date_utc
|
||||
data_type: date
|
||||
description: "Date when this standalone protection record becomes active."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: end_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp when this standalone protection record is no
|
||||
longer active. It can be null."
|
||||
|
||||
- name: end_date_utc
|
||||
data_type: date
|
||||
description: "Date when this standalone protection record is no
|
||||
longer active. It can be null."
|
||||
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: "Timestamp of when this record was extracted into DWH."
|
||||
tests:
|
||||
- not_null
|
||||
|
|
|
|||
20
models/staging/core/stg_core__basic_protection.sql
Normal file
20
models/staging/core/stg_core__basic_protection.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
with
|
||||
raw_basic_protection as (select * from {{ source("core", "BasicProtection") }}),
|
||||
stg_core__basic_protection as (
|
||||
select
|
||||
{{ adapter.quote("Id") }} as id_basic_protection,
|
||||
{{ adapter.quote("LongStay") }} as long_stay_fee_in_local_currency,
|
||||
{{ adapter.quote("ShortStay") }} as short_stay_fee_in_local_currency,
|
||||
{{ adapter.quote("CurrencyId") }} as id_currency,
|
||||
{{ adapter.quote("BasicAmount") }}
|
||||
as protection_basic_amount_in_local_currency,
|
||||
{{ adapter.quote("StartDate") }} as start_at_utc,
|
||||
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
|
||||
{{ adapter.quote("EndDate") }} as end_at_utc,
|
||||
cast({{ adapter.quote("EndDate") }} as date) as end_date_utc,
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
|
||||
from raw_basic_protection
|
||||
)
|
||||
select *
|
||||
from stg_core__basic_protection
|
||||
19
models/staging/core/stg_core__damage_waiver.sql
Normal file
19
models/staging/core/stg_core__damage_waiver.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
with
|
||||
raw_damage_waiver as (select * from {{ source("core", "DamageWaiver") }}),
|
||||
stg_core__damage_waiver as (
|
||||
select
|
||||
{{ adapter.quote("Id") }} as id_damage_waiver,
|
||||
{{ adapter.quote("BookingFee") }} as booking_fee_in_local_currency,
|
||||
{{ adapter.quote("CurrencyId") }} as id_currency,
|
||||
{{ adapter.quote("BasicAmount") }}
|
||||
as protection_basic_amount_in_local_currency,
|
||||
{{ adapter.quote("StartDate") }} as start_at_utc,
|
||||
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
|
||||
{{ adapter.quote("EndDate") }} as end_at_utc,
|
||||
cast({{ adapter.quote("EndDate") }} as date) as end_date_utc,
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
|
||||
from raw_damage_waiver
|
||||
)
|
||||
select *
|
||||
from stg_core__damage_waiver
|
||||
22
models/staging/core/stg_core__screen_and_protect.sql
Normal file
22
models/staging/core/stg_core__screen_and_protect.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
with
|
||||
raw_screen_and_protect as (select * from {{ source("core", "ScreenAndProtect") }}),
|
||||
stg_core__screen_and_protect as (
|
||||
select
|
||||
{{ adapter.quote("Id") }} as id_screen_and_protect,
|
||||
{{ adapter.quote("LongStay") }} as long_stay_fee_in_local_currency,
|
||||
{{ adapter.quote("ShortStay") }} as short_stay_fee_in_local_currency,
|
||||
{{ adapter.quote("CurrencyId") }} as id_currency,
|
||||
{{ adapter.quote("BasicAmount") }}
|
||||
as protection_basic_amount_in_local_currency,
|
||||
{{ adapter.quote("ExtendedAmount") }}
|
||||
as protection_extended_amount_in_local_currency,
|
||||
{{ adapter.quote("StartDate") }} as start_at_utc,
|
||||
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
|
||||
{{ adapter.quote("EndDate") }} as end_at_utc,
|
||||
cast({{ adapter.quote("EndDate") }} as date) as end_date_utc,
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
|
||||
from raw_screen_and_protect
|
||||
)
|
||||
select *
|
||||
from stg_core__screen_and_protect
|
||||
24
models/staging/core/stg_core__standalone_protection.sql
Normal file
24
models/staging/core/stg_core__standalone_protection.sql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
with
|
||||
raw_standalone_protection as (
|
||||
select * from {{ source("core", "StandaloneProtection") }}
|
||||
),
|
||||
stg_core__standalone_protection as (
|
||||
select
|
||||
{{ adapter.quote("Id") }} as id_standalone_protection,
|
||||
{{ adapter.quote("LongStay") }} as long_stay_fee_in_local_currency,
|
||||
{{ adapter.quote("ShortStay") }} as short_stay_fee_in_local_currency,
|
||||
{{ adapter.quote("CurrencyId") }} as id_currency,
|
||||
{{ adapter.quote("StartingAmount") }}
|
||||
as protection_starting_amount_in_local_currency,
|
||||
{{ adapter.quote("ExtendedAmount") }}
|
||||
as protection_extended_amount_in_local_currency,
|
||||
{{ adapter.quote("StartDate") }} as start_at_utc,
|
||||
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
|
||||
{{ adapter.quote("EndDate") }} as end_at_utc,
|
||||
cast({{ adapter.quote("EndDate") }} as date) as end_date_utc,
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
|
||||
from raw_standalone_protection
|
||||
)
|
||||
select *
|
||||
from stg_core__standalone_protection
|
||||
Loading…
Add table
Add a link
Reference in a new issue