Staging model for all screen & protect price tables

This commit is contained in:
Joaquin Ossa 2024-12-18 14:48:36 +01:00
parent 384665c487
commit 463226a44b
6 changed files with 444 additions and 0 deletions

View file

@ -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

View file

@ -1443,3 +1443,360 @@ 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
data_type: numeric
description: "Nightly fee for long stay bookings"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 1000
strictly: true
- name: short_stay_fee
data_type: numeric
description: "Nightly fee 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
data_type: bigint
description: "Amount 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
data_type: numeric
description: "Nightly fee 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
data_type: bigint
description: "Amount 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
data_type: numeric
description: "Nightly fee for long stay bookings."
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 1000
strictly: true
- name: short_stay_fee
data_type: numeric
description: "Nightly fee 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
data_type: bigint
description: "Amount 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
data_type: bigint
description: "Amount 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
data_type: numeric
description: "Nightly fee for long stay bookings."
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 1000
strictly: true
- name: short_stay_fee
data_type: numeric
description: "Nightly fee 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
data_type: bigint
description: "Starting amount 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
data_type: bigint
description: "Extended amount 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

View file

@ -0,0 +1,19 @@
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,
{{ adapter.quote("ShortStay") }} as short_stay_fee,
{{ adapter.quote("CurrencyId") }} as id_currency,
{{ adapter.quote("BasicAmount") }} as protection_basic_amount,
{{ 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

View file

@ -0,0 +1,18 @@
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,
{{ adapter.quote("CurrencyId") }} as id_currency,
{{ adapter.quote("BasicAmount") }} as protection_basic_amount,
{{ 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

View file

@ -0,0 +1,20 @@
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,
{{ adapter.quote("ShortStay") }} as short_stay_fee,
{{ adapter.quote("CurrencyId") }} as id_currency,
{{ adapter.quote("BasicAmount") }} as protection_basic_amount,
{{ adapter.quote("ExtendedAmount") }} as protection_extended_amount,
{{ 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

View file

@ -0,0 +1,22 @@
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,
{{ adapter.quote("ShortStay") }} as short_stay_fee,
{{ adapter.quote("CurrencyId") }} as id_currency,
{{ adapter.quote("StartingAmount") }} as protection_starting_amount,
{{ adapter.quote("ExtendedAmount") }} as protection_extended_amount,
{{ 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