Merged PR 2593: Modifying int_core__user_host to take into account KYG users
# Description Adds the possibility of considering as Hosts those users that come from Know Your Guest (KYG), after the discussion with Ben R yesterday. This uses the Claim table, specifically on any Kyg claim type: - KygRegistrationSignUpType - KygRegistrationIntegrationTypeName - KygMvp From what I see compiling the new vs. the previous version of this model and running into production to have up-to-date data, this increases the number of hosts in 8, from 2.608 to 2.616 so it's not a massive change in volumes. I also modified the schema for this model to reflect the new logic. # 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. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #19513
This commit is contained in:
parent
8171fda345
commit
68f490f9fa
2 changed files with 23 additions and 3 deletions
|
|
@ -1,16 +1,30 @@
|
|||
{% set host_roles = "('EDEPOSIT', 'HOST', 'KNOWYOURGUEST', 'PLATFORM', 'PROPERTYVERIFICATIONMANAGER', 'SCREENINGAPI')" %}
|
||||
{% set kyg_claim_types = "('KYGREGISTRATIONSIGNUPTYPE','KYGREGISTRATIONINTEGRATIONTYPENAME','KYGMVP')" %}
|
||||
|
||||
{{ config(materialized="table", unique_key="id_user_host") }}
|
||||
|
||||
with
|
||||
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),
|
||||
int_core__user_role as (select * from {{ ref("int_core__user_role") }}),
|
||||
stg_core__claim as (select * from {{ ref("stg_core__claim") }}),
|
||||
|
||||
-- A USER CAN HAVE MULTIPLE ROLES, THUS DISTINCT IS NEEDED TO AVOID DUPLICATES
|
||||
users_with_host_roles as (
|
||||
select distinct id_user
|
||||
from int_core__user_role
|
||||
where upper(role_name) in {{ host_roles }}
|
||||
),
|
||||
-- A USER CAN COME FROM KNOW YOUR GUEST (KYG)
|
||||
users_from_kyg as (
|
||||
select distinct id_user
|
||||
from stg_core__claim
|
||||
where upper(claim_type) in {{ kyg_claim_types }}
|
||||
),
|
||||
-- DEDUPLICATION
|
||||
unique_host_user as (
|
||||
select coalesce(r.id_user, k.id_user) as id_user
|
||||
from users_with_host_roles r
|
||||
full outer join users_from_kyg k on r.id_user = k.id_user
|
||||
)
|
||||
select
|
||||
uu.id_user as id_user_host,
|
||||
|
|
@ -28,4 +42,4 @@ select
|
|||
uu.created_date_utc,
|
||||
uu.updated_date_utc
|
||||
from int_core__unified_user uu
|
||||
inner join users_with_host_roles hr on uu.id_user = hr.id_user
|
||||
inner join unique_host_user uhu on uu.id_user = uhu.id_user
|
||||
|
|
|
|||
|
|
@ -1824,7 +1824,8 @@ models:
|
|||
This table provides information of the users that act as Hosts.
|
||||
A Host needs to be understood in the broad sense of the term. Here host means any
|
||||
user that acts as a "B2B" client.
|
||||
The categorisation as a Host is based on the role of the user. Any user that has
|
||||
The categorisation as a Host is based on two possibilities: the role of the user or if
|
||||
the user comes from Know Your Guest (KYG) within the claim table. Any user that has
|
||||
any of the following roles will be considered as a Host in this table:
|
||||
- Host
|
||||
- Platform
|
||||
|
|
@ -1832,7 +1833,12 @@ models:
|
|||
- KnowYourGuest
|
||||
- ScreeningAPI
|
||||
- PropertyVerificationManager
|
||||
|
||||
Additionally, any user that has any of these claim types will be considered as a Host:
|
||||
- KygRegistrationSignUpType
|
||||
- KygRegistrationIntegrationTypeName
|
||||
- KygMvp
|
||||
Lastly, in case a user satisfies multiple conditions, it will only appear once in this table.
|
||||
|
||||
columns:
|
||||
- name: id_user_host
|
||||
data_type: character varying
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue