Merged PR 3771: Intermediate and reporting models

# Description

Intermediate and reporting models for Screen and Protect verifications.
Added a field I missed before, ProtectionType

# 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.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

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

intermediate and reporting models

Related work items: #25243
This commit is contained in:
Joaquin Ossa 2024-12-04 13:51:03 +00:00
commit 0b6612f25b
6 changed files with 538 additions and 0 deletions

View file

@ -0,0 +1,48 @@
with
stg_screen_and_protect__verification_requests as (
select * from {{ ref("stg_screen_and_protect__verification_requests") }}
)
select
-- note that these ids are not the same as the ones found in Core DWH
-- they are completely unrelated
id_verification,
id_booking,
id_user_partner,
id_accommodation,
protection_type,
protection_basic_amount,
protection_extended_amount,
pet_protection,
verification_status,
verification_status_reason,
email_flag,
phone_flag,
watch_list,
channel,
checkin_date_utc,
checkout_date_utc,
checkout_date_utc - checkin_date_utc as number_of_nights,
is_cancelled,
cancelled_at_utc,
cancelled_date_utc,
user_email,
guest_email,
guest_last_name,
guest_first_name,
guest_telephone,
company_name,
property_manager_name,
property_manager_email,
listing_name,
listing_address,
listing_town,
listing_country,
listing_postcode,
pets_allowed,
status_updated_at_utc,
status_updated_date_utc,
updated_at_utc,
updated_date_utc,
created_at_utc,
created_date_utc
from stg_screen_and_protect__verification_requests

View file

@ -0,0 +1,213 @@
version: 2
models:
- name: int_screen_and_protect__verification_requests
description: |
Records of verification requests from the Screen and Protect API. The
table tracks verification requests, their outcomes, and related metadata
about guests, listings, and partners.
columns:
- name: id_verification
data_type: text
description: Unique identifier for the verification request.
tests:
- unique
- not_null
- name: id_booking
data_type: text
description: Unique identifier for the booking associated with the verification.
tests:
- not_null
- name: id_user_partner
data_type: text
description: Identifier for the partner user initiating the verification.
tests:
- not_null
- name: id_accommodation
data_type: text
description: Identifier for the accommodation related to the booking.
- name: protection_type
data_type: text
description: Specific protection type for the request.
tests:
- not_null
- accepted_values:
values:
- "SCREEN & PROTECT"
- "BASIC PROTECTION"
- "STANDALONE PROTECTION"
- "DAMAGE WAIVER"
- "PET PROTECTION"
- name: protection_basic_amount
data_type: numeric
description: Basic protection amount for the booking.
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: true
- name: protection_extended_amount
data_type: numeric
description: Extended protection amount for the booking.
- name: pet_protection
data_type: boolean
description: Indicates if pet protection was included.
- name: verification_status
data_type: text
description: Outcome of the verification process.
tests:
- not_null
- accepted_values:
values:
- "APPROVED"
- "FLAGGED"
- "REJECTED"
- name: verification_status_reason
data_type: text
description: Reason for the verification status.
- name: email_flag
data_type: text
description: Indicates issues with the email address, if any.
- name: phone_flag
data_type: text
description: Indicates issues with the phone number, if any.
- name: watch_list
data_type: text
description: Indicates if the guest was flagged on a watchlist.
tests:
- accepted_values:
values:
- "MATCH"
- "NO MATCH"
- name: channel
data_type: text
description: Booking channel or source.
- name: checkin_date_utc
data_type: date
description: Check-in date for the booking.
- name: checkout_date_utc
data_type: date
description: Check-out date for the booking.
- name: number_of_nights
data_type: integer
description: Number of nights for the booking.
- name: is_cancelled
data_type: boolean
description: Indicates if the booking was canceled.
tests:
- not_null
- name: cancelled_at_utc
data_type: timestamp without time zone
description: Timestamp when the booking was canceled.
tests:
- not_null:
where: is_cancelled = true
- name: user_email
data_type: text
description: Email address of the user associated with the booking.
- name: guest_email
data_type: text
description: Email address of the guest.
- name: guest_last_name
data_type: text
description: Last name of the guest.
- name: guest_first_name
data_type: text
description: First name of the guest.
- name: guest_telephone
data_type: text
description: Telephone number of the guest.
- name: company_name
data_type: text
description: Name of the company associated with the booking.
- name: property_manager_name
data_type: text
description: Name of the property manager.
- name: property_manager_email
data_type: text
description: Email address of the property manager.
- name: listing_name
data_type: text
description: Name of the listing.
- name: listing_address
data_type: text
description: Address of the listing.
- name: listing_town
data_type: text
description: Town where the listing is located.
- name: listing_country
data_type: text
description: Country code where the listing is located.
- name: listing_postcode
data_type: text
description: Postcode of the listing.
- name: pets_allowed
data_type: boolean
description: Indicates if pets are allowed at the listing.
- name: status_updated_at_utc
data_type: timestamp without time zone
description: Timestamp of the last status update for the verification.
tests:
- not_null
- name: status_updated_date_utc
data_type: date
description: Date of the last status update for the verification.
tests:
- not_null
- name: updated_at_utc
data_type: timestamp without time zone
description: Timestamp of the last update to the record.
tests:
- not_null
- name: updated_date_utc
data_type: date
description: Date of the last update to the record.
tests:
- not_null
- name: created_at_utc
data_type: timestamp without time zone
description: Internal timestamp when the record was created.
tests:
- not_null
- name: created_date_utc
data_type: date
description: Internal date when the record was created.
tests:
- not_null

View file

@ -0,0 +1,213 @@
version: 2
models:
- name: screen_and_protect__verification_requests
description: |
Records of verification requests from the Screen and Protect API. The
table tracks verification requests, their outcomes, and related metadata
about guests, listings, and partners.
columns:
- name: id_verification
data_type: text
description: Unique identifier for the verification request.
tests:
- unique
- not_null
- name: id_booking
data_type: text
description: Unique identifier for the booking associated with the verification.
tests:
- not_null
- name: id_user_partner
data_type: text
description: Identifier for the partner user initiating the verification.
tests:
- not_null
- name: id_accommodation
data_type: text
description: Identifier for the accommodation related to the booking.
- name: protection_type
data_type: text
description: Specific protection type for the request.
tests:
- not_null
- accepted_values:
values:
- "SCREEN & PROTECT"
- "BASIC PROTECTION"
- "STANDALONE PROTECTION"
- "DAMAGE WAIVER"
- "PET PROTECTION"
- name: protection_basic_amount
data_type: numeric
description: Basic protection amount for the booking.
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: true
- name: protection_extended_amount
data_type: numeric
description: Extended protection amount for the booking.
- name: pet_protection
data_type: boolean
description: Indicates if pet protection was included.
- name: verification_status
data_type: text
description: Outcome of the verification process.
tests:
- not_null
- accepted_values:
values:
- "APPROVED"
- "FLAGGED"
- "REJECTED"
- name: verification_status_reason
data_type: text
description: Reason for the verification status.
- name: email_flag
data_type: text
description: Indicates issues with the email address, if any.
- name: phone_flag
data_type: text
description: Indicates issues with the phone number, if any.
- name: watch_list
data_type: text
description: Indicates if the guest was flagged on a watchlist.
tests:
- accepted_values:
values:
- "MATCH"
- "NO MATCH"
- name: channel
data_type: text
description: Booking channel or source.
- name: checkin_date_utc
data_type: date
description: Check-in date for the booking.
- name: checkout_date_utc
data_type: date
description: Check-out date for the booking.
- name: number_of_nights
data_type: integer
description: Number of nights for the booking.
- name: is_cancelled
data_type: boolean
description: Indicates if the booking was canceled.
tests:
- not_null
- name: cancelled_at_utc
data_type: timestamp without time zone
description: Timestamp when the booking was canceled.
tests:
- not_null:
where: is_cancelled = true
- name: user_email
data_type: text
description: Email address of the user associated with the booking.
- name: guest_email
data_type: text
description: Email address of the guest.
- name: guest_last_name
data_type: text
description: Last name of the guest.
- name: guest_first_name
data_type: text
description: First name of the guest.
- name: guest_telephone
data_type: text
description: Telephone number of the guest.
- name: company_name
data_type: text
description: Name of the company associated with the booking.
- name: property_manager_name
data_type: text
description: Name of the property manager.
- name: property_manager_email
data_type: text
description: Email address of the property manager.
- name: listing_name
data_type: text
description: Name of the listing.
- name: listing_address
data_type: text
description: Address of the listing.
- name: listing_town
data_type: text
description: Town where the listing is located.
- name: listing_country
data_type: text
description: Country code where the listing is located.
- name: listing_postcode
data_type: text
description: Postcode of the listing.
- name: pets_allowed
data_type: boolean
description: Indicates if pets are allowed at the listing.
- name: status_updated_at_utc
data_type: timestamp without time zone
description: Timestamp of the last status update for the verification.
tests:
- not_null
- name: status_updated_date_utc
data_type: date
description: Date of the last status update for the verification.
tests:
- not_null
- name: updated_at_utc
data_type: timestamp without time zone
description: Timestamp of the last update to the record.
tests:
- not_null
- name: updated_date_utc
data_type: date
description: Date of the last update to the record.
tests:
- not_null
- name: created_at_utc
data_type: timestamp without time zone
description: Internal timestamp when the record was created.
tests:
- not_null
- name: created_date_utc
data_type: date
description: Internal date when the record was created.
tests:
- not_null

View file

@ -0,0 +1,48 @@
with
int_screen_and_protect__verification_requests as (
select * from {{ ref("int_screen_and_protect__verification_requests") }}
)
select
-- note that these ids are not the same as the ones found in Core DWH
-- they are completely unrelated
id_verification as id_verification,
id_booking as id_booking,
id_user_partner as id_user_partner,
id_accommodation as id_accommodation,
protection_type as protection_type,
protection_basic_amount as protection_basic_amount,
protection_extended_amount as protection_extended_amount,
pet_protection as pet_protection,
verification_status as verification_status,
verification_status_reason as verification_status_reason,
email_flag as email_flag,
phone_flag as phone_flag,
watch_list as watch_list,
channel as channel,
checkin_date_utc as checkin_date_utc,
checkout_date_utc as checkout_date_utc,
number_of_nights as number_of_nights,
is_cancelled as is_cancelled,
cancelled_at_utc as cancelled_at_utc,
cancelled_date_utc as cancelled_date_utc,
user_email as user_email,
guest_email as guest_email,
guest_last_name as guest_last_name,
guest_first_name as guest_first_name,
guest_telephone as guest_telephone,
company_name as company_name,
property_manager_name as property_manager_name,
property_manager_email as property_manager_email,
listing_name as listing_name,
listing_address as listing_address,
listing_town as listing_town,
listing_country as listing_country,
listing_postcode as listing_postcode,
pets_allowed as pets_allowed,
status_updated_at_utc as status_updated_at_utc,
status_updated_date_utc as status_updated_date_utc,
updated_at_utc as updated_at_utc,
updated_date_utc as updated_date_utc,
created_at_utc as created_at_utc,
created_date_utc as created_date_utc
from int_screen_and_protect__verification_requests

View file

@ -30,6 +30,19 @@ models:
data_type: text
description: Identifier for the accommodation related to the booking.
- name: protection_type
data_type: text
description: Specific protection type for the request.
tests:
- not_null
- accepted_values:
values:
- "SCREEN & PROTECT"
- "BASIC PROTECTION"
- "STANDALONE PROTECTION"
- "DAMAGE WAIVER"
- "PET PROTECTION"
- name: protection_basic_amount
data_type: numeric
description: Basic protection amount for the booking.

View file

@ -11,6 +11,9 @@ with
{{ adapter.quote("documents") }} ->> 'BookingId' as id_booking,
{{ adapter.quote("documents") }} ->> 'userId' as id_user_partner,
{{ adapter.quote("documents") }} ->> 'ListingId' as id_accommodation,
upper(
{{ adapter.quote("documents") }} ->> 'ProtectionType'
) as protection_type,
cast(
{{ adapter.quote("documents") }}
->> 'ProtectionBasicAmount' as decimal(19, 4)