diff --git a/models/intermediate/core/int_core__guest_products.sql b/models/intermediate/core/int_core__guest_products.sql new file mode 100644 index 0000000..d4ee467 --- /dev/null +++ b/models/intermediate/core/int_core__guest_products.sql @@ -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 diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index aa7d896..56fef64 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -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.