data-dwh-dbt-project/models/intermediate/edeposit/int_edeposit__verifications.sql

50 lines
1.4 KiB
MySQL
Raw Normal View History

2024-08-27 14:55:29 +02:00
with
stg_edeposit__verifications as (
select * from {{ ref("stg_edeposit__verifications") }}
)
select
-- note that these ids are not the same as the ones found in Core DWH
-- they are completely unrelated
id_verification,
2024-08-28 09:58:14 +02:00
id_booking,
id_user as id_user_partner,
2024-08-28 12:04:05 +02:00
id_listing as id_accommodation,
version, -- V1 for Guesty and V2 for E-deposit
2024-08-28 12:04:05 +02:00
case
when version = 'V1' then 'Guesty' when version = 'V2' then 'Edeposit' else null
end as verification_source,
2024-08-28 09:58:14 +02:00
verification_status,
verification_status_reason,
nightly_fee_local,
2024-08-28 09:58:14 +02:00
cast(checkout_at_utc as date) - cast(checkin_at_utc as date) as number_nights,
email_flag,
phone_flag,
watch_list,
channel,
checkin_at_utc,
cast(checkin_at_utc as date) as checkin_date_utc,
2024-08-28 09:58:14 +02:00
checkout_at_utc,
cast(checkout_at_utc as date) as checkout_date_utc,
2024-08-28 09:58:14 +02:00
is_cancelled,
cancelled_at_utc,
user_email,
guest_email,
guest_last_name,
guest_first_name,
guest_telephone,
company_name,
property_manager_name,
property_manager_email,
listing_name,
listing_town,
listing_country,
listing_postcode,
pets_allowed,
level_of_protection_amount,
level_of_protection_currency,
status_updated_at_utc,
updated_at_utc,
creation_at_utc,
created_at_utc
from stg_edeposit__verifications