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:
commit
1c1af44e76
1 changed files with 17 additions and 3 deletions
|
|
@ -6,14 +6,28 @@
|
||||||
unique_key=["date", "id_deal", "has_payment", "has_id_check"],
|
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
|
select
|
||||||
-- Unique Key --
|
-- Unique Key --
|
||||||
b.check_in_date_utc as date,
|
b.check_in_date_utc as date,
|
||||||
coalesce(icuh.id_deal, 'UNSET') as id_deal,
|
coalesce(icuh.id_deal, 'UNSET') as id_deal,
|
||||||
case
|
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,
|
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 --
|
-- Dimensions --
|
||||||
coalesce(
|
coalesce(
|
||||||
icd.main_billing_country_iso_3_per_deal, 'UNSET'
|
icd.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||||
|
|
@ -86,7 +100,7 @@ select
|
||||||
) as average_csat_score
|
) as average_csat_score
|
||||||
from {{ ref("int_core__verification_requests") }} as vr
|
from {{ ref("int_core__verification_requests") }} as vr
|
||||||
inner join
|
inner join
|
||||||
{{ ref("int_core__bookings") }} as b
|
unique_bookings_verification_request as b
|
||||||
on b.id_verification_request = vr.id_verification_request
|
on b.id_verification_request = vr.id_verification_request
|
||||||
left join
|
left join
|
||||||
{{ ref("int_core__user_host") }} as icuh on vr.id_user_host = icuh.id_user_host
|
{{ ref("int_core__user_host") }} as icuh on vr.id_user_host = icuh.id_user_host
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue