Merged PR 2652: Adds accommodation to product bundle in intermediate

# Description

Adds accommodation to product bundle in intermediate. The source table is currently empty, because there's no product bundle different to Basic Screening applied into a listing yet.
Thus, it's possible that this modelisation needs to change in the future since not having data forces us to trust the business logic without a proper technical documentation.

# Checklist

- [ ] The edited models and dependants run properly with production data. **N/A no data**
- [X] The edited models are sufficiently documented.
- [ ] The edited models contain PK tests, and I've ran and passed them. **N/A no data**
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models. **N/A no data - but view should make the trick for the time being**

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #19570
This commit is contained in:
Oriol Roqué Paniagua 2024-08-27 14:05:24 +00:00
parent 67468a3220
commit 00b8c66709
2 changed files with 175 additions and 0 deletions

View file

@ -0,0 +1,42 @@
with
stg_core__accommodation_to_product_bundle as (
select * from {{ ref("stg_core__accommodation_to_product_bundle") }}
),
int_core__user_product_bundle as (
select * from {{ ref("int_core__user_product_bundle") }}
)
select
atpb.id_accommodation_to_product_bundle,
atpb.id_accommodation,
atpb.id_user_product_bundle,
upb.id_user_host,
upb.product_bundle_name as user_product_bundle_name,
atpb.starts_at_utc as original_starts_at_utc,
atpb.ends_at_utc as original_ends_at_utc,
/*
The following is to ensure that we cap the reporting to the
dates in which these product bundles could have been active.
For analysis and reporting purposes, it is encouraged to use
the effective fields (start_date and end_date) rather than the
backend ones (named as original_starts_at and original_ends_at).
*/
greatest(
date(atpb.starts_at_utc), upb.effective_start_date_utc
) as effective_start_date_utc,
case
when atpb.has_no_end_date
then null
else greatest(date(atpb.ends_at_utc), upb.effective_end_date_utc)
end as effective_end_date_utc,
atpb.has_no_end_date,
atpb.created_at_utc,
atpb.created_date_utc,
atpb.updated_at_utc,
atpb.updated_date_utc,
atpb.dwh_extracted_at
from stg_core__accommodation_to_product_bundle as atpb
inner join
int_core__user_product_bundle as upb
on atpb.id_user_product_bundle = upb.id_user_product_bundle

View file

@ -2504,6 +2504,139 @@ models:
description: |
Date of when this Booking to Product Bundle row was last updated in the Backend.
- name: dwh_extracted_at
data_type: timestamp with timezone
description: |
Timestamp of when this row was ingested from the Backend to the DWH.
- name: int_core__accommodation_to_product_bundle
description: |
This model contains the information of which product bundle is assigned
into an accommodation, also known as listing.
It's a subset of all accommodations since it only applies to listings that
come from hosts that have been migrated into the New Dash.
Note: to improve data quality, there's an inner join with
int_core__user_product_bundle to ensure that accommodations need to be linked
to hosts that appear in the table.
Important note: the lack of entries in this table does NOT mean that the
users do not have Product Bundles in an Accommodation. A migrated user in New
Dash have by default the Product Bundle "Basic Screening", which only contains
the Product Service "Basic Screening". This is a free, default service at the
moment of creating this model, but according to Dash Product Manager, it is
likely that this service will at some point be charged - though likely 2025.
In the meantime, it's possible an quite frequent that users that have been
migrated have Bookings without the respective Accommodation appearing in this
table. For these cases, keep in mind that this Basic Screening has this default
behavior, so it has to be modelised differently.
columns:
- name: id_accommodation_to_product_bundle
data_type: bigint
description: |
The unique identifier of this table.
tests:
- not_null
- unique
- name: id_accommodation
data_type: bigint
description: |
The identifier of the accommodation that has a product bundle.
An accommodation appearing here would mean it's under the New Dash &
the New Pricing structure; as well as having a product bundle different
than the default "Basic Screening".
Accommodations can have several entries in this table for each time
there's a change on the bundle assigned into it.
tests:
- not_null
- name: id_user_product_bundle
data_type: bigint
description: |
The identifier of the user product bundle. This allows the retrieval
of the information of the product bundle associated at the user level.
tests:
- not_null
- name: id_user_host
data_type: string
description: |
The identifier of the user that acts as a host. Only Hosts that have
New Pricing in the New Dash structure that have an accommodation with
a product bundle different than the default "Basic Screening" assigned
into it will appear in this model.
tests:
- not_null
- name: product_bundle_name
data_type: string
description: |
The CamelCase name of the Product Bundle.
- name: original_starts_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Bundle is assigned into an Accommodation was
active for the first time, according to the Backend.
Keep in mind that this timestamp can be before the migration of the user, thus
effective_start_date_utc might be better for reporting and analysis purposes.
tests:
- not_null
- name: original_ends_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Bundle is assigned into an Accommodation was
active for the last time, according to the Backend. If null it means that
it's currently active.
Keep in mind that this timestamp can be before the migration of the user, thus
effective_end_date_utc might be better for reporting and analysis purposes.
- name: effective_start_date_utc
data_type: date
description: |
Effective date of when this Product Bundle is assigned into an Accommodation was
active for the first time.
It takes into account the fact that a User needs to be migrated in order for
the Product Bundle to be active in the Accommodation. In case of doubt, use this date.
tests:
- not_null
- name: effective_end_date_utc
data_type: date
description: |
Effective date of when this Product Bundle is assigned into an Accommodation was
active for the last time. If null it means that it's currently active.
It takes into account the fact that a User needs to be migrated in order for
the Product Bundle to be active in the Accommodation. In case of doubt, use this date.
- name: has_no_end_date
data_type: boolean
description: |
Flag to determine if the end date is filled or not.
- name: created_at_utc
data_type: timestamp
description: |
Timestamp of when this Accommodation to Product Bundle row was created in the Backend.
- name: created_date_utc
data_type: date
description: |
Date of when this Accommodation to Product Bundle row was created in the Backend.
- name: updated_at_utc
data_type: timestamp
description: |
Timestamp of when this Accommodation to Product Bundle row was last updated in the Backend.
- name: updated_date_utc
data_type: date
description: |
Date of when this Accommodation to Product Bundle row was last updated in the Backend.
- name: dwh_extracted_at
data_type: timestamp with timezone
description: |