Merged PR 4699: Creates a master table for guest products

# Description

Creates a master table for guest products in intermediate. It just gathers information on the name and the latest display name, as well as a couple of additional time fields.

I opted for "latest" rather than "current" because technically Guest Products can be enabled and disabled, and I believe current name would be weird if the product is disabled. Anyway. Next step will be actually creating a master table on guest product configuration, that will handle this disable logic and so on.

# 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: #28513
This commit is contained in:
Oriol Roqué Paniagua 2025-03-14 13:04:46 +00:00
parent 72118389d6
commit 918ed969d8
2 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,26 @@
with
stg_core__guest_product_display_detail as (
select * from {{ ref("stg_core__guest_product_display_detail") }}
),
stg_core__guest_product as (select * from {{ ref("stg_core__guest_product") }}),
guest_product_display_ranked as (
select
id_guest_product,
guest_product_display_name,
starts_at_utc,
start_date_utc,
row_number() over (
partition by id_guest_product order by starts_at_utc desc
) as ranked_guest_products
from stg_core__guest_product_display_detail scgpdd
)
select
scgp.id_guest_product,
scgp.guest_product_name,
gpdr.guest_product_display_name as guest_product_latest_display_name,
gpdr.starts_at_utc as guest_product_latest_display_name_starts_at_utc,
gpdr.start_date_utc as guest_product_latest_display_name_start_date
from stg_core__guest_product scgp
left join
guest_product_display_ranked gpdr on scgp.id_guest_product = gpdr.id_guest_product
where gpdr.ranked_guest_products = 1

View file

@ -5864,3 +5864,53 @@ models:
data_type: bigint
description: |
The number of accommodations managed by the host.
- name: int_core__guest_products
description: |
Master table of Guest Products. Contains very simple information,
namely the Id of the Guest Product with its name, as well as
the latest display name and since when the latest display name
is available.
columns:
- name: id_guest_product
data_type: bigint
description: |
Identifier of the guest product.
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.
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.
data_tests:
- not_null
- name: guest_product_latest_display_name_starts_at_utc
data_type: timestamp
description: |
Timestamp of when the guest product display name started
to be in use. This is purely for information purposes.
- name: guest_product_latest_display_name_starts_date_utc
data_type: date
description: |
Date of when the guest product display name started
to be in use. This is purely for information purposes.