Merged PR 3827: S&P models update
# Description Added the missing field `is_protected` to the S&P models that comes from the `apim_users` table I also modified the `apim_users` so the json field is actually stored as a json # 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. - [ ] 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: #25243
This commit is contained in:
commit
8052581a3d
6 changed files with 75 additions and 46 deletions
|
|
@ -1,50 +1,64 @@
|
||||||
|
{% set api_name = "SCREENANDPROTECTAPI" %}
|
||||||
|
|
||||||
with
|
with
|
||||||
stg_screen_and_protect__verification_requests as (
|
stg_screen_and_protect__verification_requests as (
|
||||||
select * from {{ ref("stg_screen_and_protect__verification_requests") }}
|
select * from {{ ref("stg_screen_and_protect__verification_requests") }}
|
||||||
)
|
),
|
||||||
|
stg_core__apim_user as (select * from {{ ref("stg_core__apim_user") }}),
|
||||||
|
stg_core__apim_user_type as (select * from {{ ref("stg_core__apim_user_type") }})
|
||||||
select
|
select
|
||||||
-- note that these ids are not the same as the ones found in Core DWH
|
-- note that these ids are not the same as the ones found in Core DWH
|
||||||
-- they are completely unrelated
|
-- they are completely unrelated
|
||||||
id_verification,
|
vr.id_verification,
|
||||||
id_booking,
|
vr.id_booking,
|
||||||
id_user_partner,
|
vr.id_user_partner,
|
||||||
id_accommodation,
|
vr.id_accommodation,
|
||||||
protection_type,
|
case
|
||||||
protection_starting_level,
|
when (au.json_document_user_data ->> 'FlaggedNotProtected') = 'false'
|
||||||
protection_basic_amount,
|
then true
|
||||||
protection_extended_amount,
|
else false
|
||||||
pet_protection,
|
end as is_protected,
|
||||||
verification_status,
|
vr.protection_type,
|
||||||
verification_status_reason,
|
vr.protection_starting_level,
|
||||||
email_flag,
|
vr.protection_basic_amount,
|
||||||
phone_flag,
|
vr.protection_extended_amount,
|
||||||
watch_list,
|
vr.pet_protection,
|
||||||
channel,
|
vr.verification_status,
|
||||||
checkin_date_utc,
|
vr.verification_status_reason,
|
||||||
checkout_date_utc,
|
vr.email_flag,
|
||||||
checkout_date_utc - checkin_date_utc as number_of_nights,
|
vr.phone_flag,
|
||||||
is_cancelled,
|
vr.watch_list,
|
||||||
cancelled_at_utc,
|
vr.channel,
|
||||||
cancelled_date_utc,
|
vr.checkin_date_utc,
|
||||||
user_email,
|
vr.checkout_date_utc,
|
||||||
guest_email,
|
vr.checkout_date_utc - checkin_date_utc as number_of_nights,
|
||||||
guest_last_name,
|
vr.is_cancelled,
|
||||||
guest_first_name,
|
vr.cancelled_at_utc,
|
||||||
guest_telephone,
|
vr.cancelled_date_utc,
|
||||||
company_name,
|
vr.user_email,
|
||||||
property_manager_name,
|
vr.guest_email,
|
||||||
property_manager_email,
|
vr.guest_last_name,
|
||||||
listing_name,
|
vr.guest_first_name,
|
||||||
listing_address,
|
vr.guest_telephone,
|
||||||
listing_town,
|
vr.company_name,
|
||||||
listing_country,
|
vr.property_manager_name,
|
||||||
listing_postcode,
|
vr.property_manager_email,
|
||||||
pets_allowed,
|
vr.listing_name,
|
||||||
status_updated_at_utc,
|
vr.listing_address,
|
||||||
status_updated_date_utc,
|
vr.listing_town,
|
||||||
updated_at_utc,
|
vr.listing_country,
|
||||||
updated_date_utc,
|
vr.listing_postcode,
|
||||||
cosmos_creation_at_utc,
|
vr.pets_allowed,
|
||||||
cosmos_creation_date_utc,
|
vr.status_updated_at_utc,
|
||||||
created_date_utc
|
vr.status_updated_date_utc,
|
||||||
from stg_screen_and_protect__verification_requests
|
vr.updated_at_utc,
|
||||||
|
vr.updated_date_utc,
|
||||||
|
vr.cosmos_creation_at_utc,
|
||||||
|
vr.cosmos_creation_date_utc,
|
||||||
|
vr.created_date_utc
|
||||||
|
from stg_screen_and_protect__verification_requests vr
|
||||||
|
inner join stg_core__apim_user au on vr.id_user_partner = au.id_apim_user
|
||||||
|
inner join
|
||||||
|
stg_core__apim_user_type aut
|
||||||
|
on au.id_apim_user_type = aut.id_apim_user_type
|
||||||
|
and upper(aut.user_type_name) = '{{ api_name }}'
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@ models:
|
||||||
data_type: text
|
data_type: text
|
||||||
description: Identifier for the accommodation related to the booking.
|
description: Identifier for the accommodation related to the booking.
|
||||||
|
|
||||||
|
- name: is_protected
|
||||||
|
data_type: boolean
|
||||||
|
description: |
|
||||||
|
Indicates if the booking is protected or not.
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
- name: protection_type
|
- name: protection_type
|
||||||
data_type: text
|
data_type: text
|
||||||
description: Specific protection type for the request.
|
description: Specific protection type for the request.
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@ models:
|
||||||
data_type: text
|
data_type: text
|
||||||
description: Identifier for the accommodation related to the booking.
|
description: Identifier for the accommodation related to the booking.
|
||||||
|
|
||||||
|
- name: is_protected
|
||||||
|
data_type: boolean
|
||||||
|
description: |
|
||||||
|
Indicates if the booking is protected or not.
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
- name: protection_type
|
- name: protection_type
|
||||||
data_type: text
|
data_type: text
|
||||||
description: Specific protection type for the request.
|
description: Specific protection type for the request.
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ select
|
||||||
id_booking as id_booking,
|
id_booking as id_booking,
|
||||||
id_user_partner as id_user_partner,
|
id_user_partner as id_user_partner,
|
||||||
id_accommodation as id_accommodation,
|
id_accommodation as id_accommodation,
|
||||||
|
is_protected as is_protected,
|
||||||
protection_type as protection_type,
|
protection_type as protection_type,
|
||||||
protection_starting_level as protection_starting_level,
|
protection_starting_level as protection_starting_level,
|
||||||
protection_basic_amount as protection_basic_amount,
|
protection_basic_amount as protection_basic_amount,
|
||||||
|
|
|
||||||
|
|
@ -1381,7 +1381,7 @@ models:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: json_document_user_data
|
- name: json_document_user_data
|
||||||
data_type: character varying
|
data_type: jsonb
|
||||||
description: |
|
description: |
|
||||||
"The json document that contains the user information"
|
"The json document that contains the user information"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ with
|
||||||
select
|
select
|
||||||
{{ adapter.quote("UserId") }} as id_apim_user,
|
{{ adapter.quote("UserId") }} as id_apim_user,
|
||||||
{{ adapter.quote("ApimUserTypeId") }} as id_apim_user_type,
|
{{ adapter.quote("ApimUserTypeId") }} as id_apim_user_type,
|
||||||
{{ adapter.quote("Json") }} as json_document_user_data,
|
{{ adapter.quote("Json") }}::jsonb as json_document_user_data,
|
||||||
{{ adapter.quote("CreatedDate") }} as created_at_utc,
|
{{ adapter.quote("CreatedDate") }} as created_at_utc,
|
||||||
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
|
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
|
||||||
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
|
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue