Merged PR 3573: Removed duplicated verification requests

# Description

This change removes duplicated verification requests in bookings across different times, previously the model was only considering unique verification requests in a day but counting them twice if they were in different days.

# 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.

Related work items: #23998
This commit is contained in:
Joaquin Ossa 2024-11-19 08:27:47 +00:00
commit 1c1af44e76

View file

@ -6,14 +6,28 @@
unique_key=["date", "id_deal", "has_payment", "has_id_check"],
)
}}
with
ranked_bookings as (
select
*,
row_number() over (
partition by id_verification_request order by updated_at_utc asc
) as rn
from {{ ref("int_core__bookings") }}
),
unique_bookings_verification_request as (select * from ranked_bookings where rn = 1)
select
-- Unique Key --
b.check_in_date_utc as date,
coalesce(icuh.id_deal, 'UNSET') as id_deal,
case
when vp.id_verification_to_payment is null then 'W/O Payment' else 'With Payment'
when vp.id_verification_to_payment is null
then 'W/O Payment'
else 'With Payment'
end as has_payment,
case when v.id_verification is null then 'W/O Id Check' else 'With Id Check' end as has_id_check,
case
when v.id_verification is null then 'W/O Id Check' else 'With Id Check'
end as has_id_check,
-- Dimensions --
coalesce(
icd.main_billing_country_iso_3_per_deal, 'UNSET'
@ -86,7 +100,7 @@ select
) as average_csat_score
from {{ ref("int_core__verification_requests") }} as vr
inner join
{{ ref("int_core__bookings") }} as b
unique_bookings_verification_request as b
on b.id_verification_request = vr.id_verification_request
left join
{{ ref("int_core__user_host") }} as icuh on vr.id_user_host = icuh.id_user_host