new approach for S&P users data extraction
This commit is contained in:
parent
24aa9b7021
commit
0cebdcf160
4 changed files with 209 additions and 32 deletions
|
|
@ -1,11 +1,10 @@
|
|||
{% set api_name = "SCREENANDPROTECTAPI" %}
|
||||
|
||||
with
|
||||
stg_screen_and_protect__verification_requests as (
|
||||
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") }})
|
||||
int_core__screen_and_protect_users as (
|
||||
select * from {{ ref("int_core__screen_and_protect_users") }}
|
||||
)
|
||||
select
|
||||
-- note that these ids are not the same as the ones found in Core
|
||||
-- they are completely unrelated
|
||||
|
|
@ -13,11 +12,7 @@ select
|
|||
vr.id_booking,
|
||||
vr.id_user_partner,
|
||||
vr.id_accommodation,
|
||||
case
|
||||
when (au.json_document_user_data ->> 'FlaggedNotProtected') = 'false'
|
||||
then true
|
||||
else false
|
||||
end as is_protected,
|
||||
spu.is_protected,
|
||||
vr.protection_type,
|
||||
vr.protection_starting_level,
|
||||
vr.protection_basic_amount,
|
||||
|
|
@ -25,23 +20,15 @@ select
|
|||
vr.pet_protection,
|
||||
vr.verification_status,
|
||||
vr.verification_status_reason,
|
||||
(au.json_document_user_data ->> 'PriceIncrease')::decimal as price_increase,
|
||||
(au.json_document_user_data ->> 'PriceIncreaseStartDate')::date
|
||||
as price_increase_start_date_utc,
|
||||
(au.json_document_user_data ->> 'MonthlyVolumeDiscount')::decimal
|
||||
as monthly_volume_discount,
|
||||
(au.json_document_user_data ->> 'ThresholdApprovedBookingVolume')::integer
|
||||
as threshold_approved_booking_volume,
|
||||
(au.json_document_user_data ->> 'MonthlyVolumeDiscountStartDate')::date
|
||||
as monthly_volume_discount_start_date_utc,
|
||||
(au.json_document_user_data ->> 'MonthlyVolumeDiscountEndDate')::date
|
||||
as monthly_volume_discount_end_date_utc,
|
||||
(au.json_document_user_data ->> 'MonthlyGeneralDiscount')::decimal
|
||||
as monthly_general_discount,
|
||||
(au.json_document_user_data ->> 'MonthlyGeneralDiscountStartDate')::date
|
||||
as monthly_general_discount_start_date_utc,
|
||||
(au.json_document_user_data ->> 'MonthlyGeneralDiscountEndDate')::date
|
||||
as monthly_general_discount_end_date_utc,
|
||||
spu.price_increase,
|
||||
spu.price_increase_start_date_utc,
|
||||
spu.monthly_volume_discount,
|
||||
spu.threshold_approved_booking_volume,
|
||||
spu.monthly_volume_discount_start_date_utc,
|
||||
spu.monthly_volume_discount_end_date_utc,
|
||||
spu.monthly_general_discount,
|
||||
spu.monthly_general_discount_start_date_utc,
|
||||
spu.monthly_general_discount_end_date_utc,
|
||||
vr.email_flag,
|
||||
vr.phone_flag,
|
||||
vr.watch_list,
|
||||
|
|
@ -74,8 +61,5 @@ select
|
|||
vr.creation_date_utc,
|
||||
vr.cosmos_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 }}'
|
||||
int_core__screen_and_protect_users spu on vr.id_user_partner = spu.id_apim_user
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1
|
||||
max_value: 100
|
||||
strictly: true
|
||||
|
||||
- name: threshold_approved_booking_volume
|
||||
|
|
@ -158,7 +158,7 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1
|
||||
max_value: 100
|
||||
strictly: true
|
||||
|
||||
- name: monthly_general_discount_start_date_utc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue