Merged PR 5047: First API unified version of Verifications
# Description Creates a first unified version of API verifications. This is a very simple model as it aims to capture the minimal essence of Verifications in a unified view. Any very-in-depth-API-specific detail is not available here. Additionally, I propagated the Check-in date in the Athena model. This is needed for API Bookings KPIs future models. # 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. - [X] I've picked the right materialization for the affected models. **Currently as a view, despite it's 70k records. If this grows we could consider other materialisations** # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #29374
This commit is contained in:
parent
54e20e00d5
commit
ca2311d935
4 changed files with 199 additions and 0 deletions
81
models/intermediate/cross/int_unified_api_verifications.sql
Normal file
81
models/intermediate/cross/int_unified_api_verifications.sql
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{% set guesty_id_deal = "17814677813" %}
|
||||
with
|
||||
int_edeposit__verification_fees as (
|
||||
select * from {{ ref("int_edeposit__verification_fees") }}
|
||||
),
|
||||
int_athena__verifications_with_fees as (
|
||||
select * from {{ ref("int_athena__verifications_with_fees") }}
|
||||
),
|
||||
int_check_in_hero__checkins as (
|
||||
select * from {{ ref("int_check_in_hero__checkins") }}
|
||||
),
|
||||
int_screen_and_protect__verification_fees as (
|
||||
select * from {{ ref("int_screen_and_protect__verification_fees") }}
|
||||
)
|
||||
select
|
||||
'E-DEPOSIT' as api_source,
|
||||
id_verification,
|
||||
id_booking,
|
||||
id_deal,
|
||||
verification_status,
|
||||
checkin_date_utc as check_in_date_utc,
|
||||
checkout_date_utc as check_out_date_utc,
|
||||
created_date_utc,
|
||||
checkout_date_utc as billable_date_utc,
|
||||
is_cancelled,
|
||||
case
|
||||
when count(1) over (partition by id_booking) > 1 then true else false
|
||||
end as is_duplicate_booking,
|
||||
count(1) over (partition by id_booking) as booking_is_duplicated_n_times
|
||||
from int_edeposit__verification_fees
|
||||
union all
|
||||
select
|
||||
'ATHENA' as api_source,
|
||||
id_verification,
|
||||
id_booking,
|
||||
'{{guesty_id_deal}}' as id_deal,
|
||||
verification_status,
|
||||
checkin_date_utc as check_in_date_utc,
|
||||
checkout_date_utc as check_out_date_utc,
|
||||
created_date_utc,
|
||||
checkout_date_utc as billable_date_utc,
|
||||
is_cancelled,
|
||||
case
|
||||
when count(1) over (partition by id_booking) > 1 then true else false
|
||||
end as is_duplicate_booking,
|
||||
count(1) over (partition by id_booking) as booking_is_duplicated_n_times
|
||||
from int_athena__verifications_with_fees
|
||||
union all
|
||||
select
|
||||
'CHECK_IN_HERO' as api_source,
|
||||
id_record as id_verification,
|
||||
id_reservation as id_booking,
|
||||
id_deal,
|
||||
null as verification_status,
|
||||
checkin_date_utc as check_in_date_utc,
|
||||
checkout_date_utc as check_out_date_utc,
|
||||
created_date_utc,
|
||||
created_date_utc as billable_date_utc,
|
||||
null as is_cancelled,
|
||||
case
|
||||
when count(1) over (partition by id_reservation) > 1 then true else false
|
||||
end as is_duplicate_booking,
|
||||
count(1) over (partition by id_reservation) as booking_is_duplicated_n_times
|
||||
from int_check_in_hero__checkins
|
||||
union all
|
||||
select
|
||||
'SCREEN_AND_PROTECT' as api_source,
|
||||
id_verification,
|
||||
id_booking,
|
||||
id_deal,
|
||||
verification_status,
|
||||
checkin_date_utc as check_in_date_utc,
|
||||
checkout_date_utc as check_out_date_utc,
|
||||
creation_date_utc as created_date_utc,
|
||||
invoice_date_utc as billable_date_utc,
|
||||
is_cancelled,
|
||||
case
|
||||
when count(1) over (partition by id_booking) > 1 then true else false
|
||||
end as is_duplicate_booking,
|
||||
count(1) over (partition by id_booking) as booking_is_duplicated_n_times
|
||||
from int_screen_and_protect__verification_fees
|
||||
Loading…
Add table
Add a link
Reference in a new issue