Merged PR 4686: Guest Products - Sync Guest Products

# Description

Adds the remaining Guest Products tables to staging

# 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: #28490
This commit is contained in:
Oriol Roqué Paniagua 2025-03-13 11:53:04 +00:00
parent 7ef460a59e
commit eb26252784
6 changed files with 559 additions and 4 deletions

View file

@ -1905,7 +1905,7 @@ models:
Indicates if the guest product was purchased.
- name: created_at_utc
data_type: timestamp with time zone
data_type: timestamp
description: |
Timestamp of when this record was created.
data_tests:
@ -1919,7 +1919,7 @@ models:
- not_null
- name: updated_at_utc
data_type: timestamp with time zone
data_type: timestamp
description: |
Timestamp of when this record was last updated.
data_tests:
@ -1968,7 +1968,7 @@ models:
- not_null
- name: created_at_utc
data_type: timestamp with time zone
data_type: timestamp
description: |
Timestamp of when this record was created.
data_tests:
@ -1982,7 +1982,390 @@ models:
- not_null
- name: updated_at_utc
data_type: timestamp with time zone
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
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: |
Timestamp of when this record was extracted into DWH.
- name: stg_core__guest_product_configuration
description: |
Contains the configuration of a guest product. This table is used to track
the configuration of a guest product.
columns:
- name: id_guest_product_configuration
data_type: bigint
description: |
Unique identifier of the guest product configuration.
Acts as the primary key for this table.
data_tests:
- not_null
- unique
- name: id_guest_product
data_type: bigint
description: |
Identifier of the guest product.
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.
data_tests:
- not_null
- accepted_values:
values:
- DEFAULT
- ACCOUNT
- 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
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: |
Timestamp of when this record was extracted into DWH.
- name: stg_core__guest_product
description: |
Contains the internal name for the guest product. Be aware that this
might be different than the commercial name, namely, the display name.
columns:
- name: id_guest_product
data_type: bigint
description: |
Unique identifier of the guest product.
Acts as the primary key for this table.
data_tests:
- not_null
- unique
- name: guest_product_name
data_type: character varying
description: |
Name of the guest product in capital letters.
This is the internal name, not necessarily the
commercial name.
data_tests:
- not_null
- accepted_values:
values:
- STAYDISRUPT
- CHECKINCOVER
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: |
Timestamp of when this record was extracted into DWH.
- name: stg_core__guest_product_configuration_status
description: |
Contains the status of a guest product configuration.
It's used to determine if the configuration is active or not.
columns:
- name: id_guest_product_configuration_status
data_type: bigint
description: |
Unique identifier of the guest product configuration status.
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: is_enabled
data_type: boolean
description: |
Indicates if the configuration is 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.
data_tests:
- not_null
- name: is_enabled_for_guest_journey
data_type: boolean
description: |
Indicates if the configuration is enabled for the guest journey.
- If true, then the product is visible in the guest journey.
data_tests:
- not_null
- name: starts_at_utc
data_type: timestamp
description: |
Timestamp of when this configuration status starts.
data_tests:
- not_null
- name: start_date_utc
data_type: date
description: |
Date of when this configuration status starts.
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
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: |
Timestamp of when this record was extracted into DWH.
- name: stg_core__guest_product_configuration_price_plan
description: |
Contains the price plan of a guest product configuration.
It contains, for each configuration and currency, the guest
product price and the protection limit.
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- id_guest_product_configuration
- id_currency
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: id_currency
data_type: bigint
description: |
Identifier of the currency.
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: 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
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: |
Timestamp of when this record was extracted into DWH.
- name: stg_core__guest_product_display_detail
description: |
Contains the display details of a guest product.
It contains the display name for commercial purposes as
well as the display order. It's historified to keep track
of the commercial name changes.
columns:
- name: id_guest_product_display_detail
data_type: bigint
description: |
Unique identifier of the guest product display detail.
Acts as the primary key for this table.
data_tests:
- not_null
- unique
- name: id_guest_product
data_type: bigint
description: |
Identifier of the guest product.
data_tests:
- not_null
- name: guest_product_display_name
data_type: character varying
description: |
Display name of the guest product.
data_tests:
- not_null
- accepted_values:
values:
- DISRUPTION HERO
- CHECKIN HERO
- name: guest_product_display_order
data_type: integer
description: |
Display order of the guest product.
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 display detail starts.
data_tests:
- not_null
- name: start_date_utc
data_type: date
description: |
Date of when this display detail starts.
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:

View file

@ -0,0 +1,12 @@
with
raw_guest_product as (select * from {{ source("guest_product", "Product") }}),
stg_core__guest_product as (
select
{{ adapter.quote("Id") }} as id_guest_product,
upper({{ adapter.quote("Name") }}) as guest_product_name,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_guest_product
)
select *
from stg_core__guest_product

View file

@ -0,0 +1,53 @@
{{
config(
materialized="incremental",
unique_key="id_guest_product_configuration",
)
}}
with
raw_configuration_level as (
select
{{ adapter.quote("Id") }} as id,
upper({{ adapter.quote("Name") }}) as configuration_name
from {{ source("guest_product", "ConfigurationLevel") }}
),
raw_configuration as (
select
{{ adapter.quote("Id") }} as id_guest_product_configuration,
{{ adapter.quote("GuestProductId") }} as id_guest_product,
{{ adapter.quote("GuestProductConfigurationLevelId") }}
as id_guest_product_configuration_level,
lower({{ adapter.quote("HostUserId") }}) as id_user_host,
{{ adapter.quote("StartDate") }} as starts_at_utc,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from {{ source("guest_product", "Configuration") }}
)
select
rc.id_guest_product_configuration,
rc.id_guest_product,
rcl.configuration_name as configuration_level,
rc.id_user_host,
rc.starts_at_utc,
rc.created_at_utc,
rc.created_date_utc,
rc.updated_at_utc,
rc.updated_date_utc,
rc.dwh_extracted_at_utc
from raw_configuration rc
left join
raw_configuration_level rcl on rc.id_guest_product_configuration_level = rcl.id
{% if is_incremental() %}
where
updated_at_utc
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
{% endif %}

View file

@ -0,0 +1,43 @@
{{
config(
materialized="incremental",
unique_key="id_guest_product_configuration_price_plan",
)
}}
with
raw_guest_product_configuration_price_plan as (
select * from {{ source("guest_product", "ConfigurationPricePlan") }}
),
stg_core__guest_product_configuration_price_plan as (
select
{{ adapter.quote("Id") }} as id_guest_product_configuration_price_plan,
{{ adapter.quote("GuestProductConfigurationId") }}
as id_guest_product_configuration,
{{ adapter.quote("CurrencyId") }} as id_currency,
cast(
{{ adapter.quote("Amount") }} as float
) as product_price_in_local_currency,
cast(
{{ adapter.quote("Limit") }} as float
) as protection_limit_in_local_currency,
{{ adapter.quote("StartDate") }} as starts_at_utc,
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_guest_product_configuration_price_plan
)
select *
from stg_core__guest_product_configuration_price_plan
{% if is_incremental() %}
where
updated_at_utc
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
{% endif %}

View file

@ -0,0 +1,40 @@
{{
config(
materialized="incremental",
unique_key="id_guest_product_configuration_status",
)
}}
with
raw_guest_product_configuration_status as (
select * from {{ source("guest_product", "ConfigurationStatus") }}
),
stg_core__guest_product_configuration_status as (
select
{{ adapter.quote("Id") }} as id_guest_product_configuration_status,
{{ adapter.quote("GuestProductConfigurationId") }}
as id_guest_product_configuration,
cast({{ adapter.quote("IsEnabled") }} as boolean) as is_enabled,
cast(
{{ adapter.quote("IsEnabledForGuestJourney") }} as boolean
) as is_enabled_for_guest_journey,
{{ adapter.quote("StartDate") }} as starts_at_utc,
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_guest_product_configuration_status
)
select *
from stg_core__guest_product_configuration_status
{% if is_incremental() %}
where
updated_at_utc
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
{% endif %}

View file

@ -0,0 +1,24 @@
with
raw_guest_product_display_detail as (
select * from {{ source("guest_product", "DisplayDetail") }}
),
stg_core__guest_product_display_detail as (
select
{{ adapter.quote("Id") }} as id_guest_product_display_detail,
{{ adapter.quote("GuestProductId") }} as id_guest_product,
upper({{ adapter.quote("DisplayName") }}) as guest_product_display_name,
{{ adapter.quote("DisplayOrder") }} as guest_product_display_order,
{{ adapter.quote("StartDate") }} as starts_at_utc,
cast({{ adapter.quote("StartDate") }} as date) as start_date_utc,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_guest_product_display_detail
)
select *
from stg_core__guest_product_display_detail