Merged PR 3878: Propagates account type to intermediate

# Description

Propagates account type to intermediate. Also, adds minimal documentation to `int_core__unified_user`.

There's only 54 test accounts in Unified User and 49 that are considered as User Hosts. So it's not, by all means, an extensive list of test accounts...

There's a mismatch between the `created_date_utc` and `updated_date_utc` that these are timestamps. There's another ticket in the backlog to handle this alongside the dependency, so it's not included here.

# 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: #18944
This commit is contained in:
Oriol Roqué Paniagua 2024-12-19 16:33:35 +00:00
parent 7b28bbb925
commit b20b819456
3 changed files with 160 additions and 6 deletions

View file

@ -1,11 +1,15 @@
{% set test_account_type_name = "('TEST')" %}
with
stg_core__user as (select * from {{ ref("stg_core__user") }}),
stg_core__superhog_user as (select * from {{ ref("stg_core__superhog_user") }}),
stg_core__currency as (select * from {{ ref("stg_core__currency") }}),
stg_core__country as (select * from {{ ref("stg_core__country") }})
stg_core__country as (select * from {{ ref("stg_core__country") }}),
stg_core__account_type as (select * from {{ ref("stg_core__account_type") }})
select
u.id_user,
u.id_account_type,
act.account_type_display_name as account_type,
u.id_billing_country,
co.country_name as billing_country_name,
co.iso_2 as billing_country_iso_2,
@ -42,8 +46,12 @@ select
su.number_of_properties,
su.id_superhog_verified_set,
su.platform_comms_recipient,
su.id_user_verification_status
su.id_user_verification_status,
case
when act.account_type_name in {{ test_account_type_name }} then true else false
end as is_test_account
from stg_core__user as u
inner join stg_core__superhog_user as su on u.id_user = su.id_superhoguser
left join stg_core__currency cu on u.id_account_currency = cu.id_currency
left join stg_core__country co on u.id_billing_country = co.id_country
left join stg_core__account_type act on u.id_account_type = act.id_account_type

View file

@ -30,7 +30,8 @@ with
)
select
uu.id_user as id_user_host,
uu.id_account_type,
uu.account_type,
uu.is_test_account,
uu.id_billing_country,
uu.billing_country_name,
uu.billing_country_iso_2,

View file

@ -178,6 +178,144 @@ models:
tests:
- not_null
- unique
- name: id_account_type
data_type: bigint
description: |
The ID of the account type. Might be null and not necessarily up to date.
- name: account_type
data_type: character varying
description: |
The name of the account type. Might be null and not necessarily up to date.
- name: id_billing_country
data_type: bigint
description: The ID of the billing country. Can be null.
- name: billing_country_name
data_type: character varying
description: The name of the billing country. Can be null.
- name: billing_country_iso_2
data_type: char(2)
description: The ISO 3166-1 alpha-2 code of the billing country. Can be null.
- name: billing_country_iso_3
data_type: char(3)
description: The ISO 3166-1 alpha-3 code of the billing country. Can be null.
- name: account_currency_iso4217
data_type: char(3)
description: The ISO 4217 code of the account currency. Can be null.
- name: user_code
data_type: bigint
description: The user code.
- name: first_name
data_type: character varying
description: The first name of the user.
- name: last_name
data_type: character varying
description: The last name of the user.
- name: email
data_type: character varying
description: The email of the user.
- name: phone_number
data_type: character varying
description: The phone number of the user.
- name: title
data_type: character varying
description: The title of the user.
- name: id_deal
data_type: character varying
description: |
The ID of the deal of the user. It only applies to client accounts.
Can be null.
- name: is_deleted
data_type: boolean
description: |
True if the user has been deleted. False otherwise.
- name: joined_at_utc
data_type: timestamp
description: The timestamp when the user joined.
- name: joined_date_utc
data_type: date
description: The date when the user joined.
- name: user_name
data_type: character varying
description: The user name.
- name: code_prefix
data_type: character varying
description: The code prefix.
- name: billing_town
data_type: character varying
description: The billing town.
- name: company_name
data_type: character varying
description: The company name.
- name: is_email_confirmed
data_type: boolean
description: |
True if the email of the user has been confirmed. False otherwise.
- name: is_lockout_enabled
data_type: boolean
description: |
True if the lockout has been enabled. False otherwise.
- name: billing_postcode
data_type: character varying
description: The billing postcode.
- name: is_twofactor_enabled
data_type: boolean
description: |
True if the two-factor authentication has been enabled. False otherwise.
- name: access_failed_count
data_type: bigint
description: The access failed count.
- name: lockout_end_date_utc
data_type: timestamp
description: The lockout end date.
- name: avatar
data_type: character varying
description: The avatar of the user.
- name: id_airbnb
data_type: character varying
description: The ID of the Airbnb.
- name: airbnb_url
data_type: character varying
description: The Airbnb URL.
- name: created_date_utc
data_type: timestamp
description: The timestamp when the user was created. The field name needs to be fixed.
- name: updated_date_utc
data_type: timestamp
description: The timestamp when the user was updated. The field name needs to be fixed.
- name: verified_at_utc
data_type: timestamp
description: The timestamp when the user was verified.
- name: verified_date_utc
data_type: date
description: The date when the user was verified.
- name: flag_as_problem
data_type: boolean
description: |
True if the user has been flagged as a problem. False otherwise.
- name: number_of_properties
data_type: bigint
description: |
The number of properties according to the backend. For a better
figure we recommend using Hubspot data. For a real figure
of properties actually being active in our business, we recommend
using other sources of data.
- name: id_superhog_verified_set
data_type: bigint
description: The ID of the Superhog verified set.
- name: platform_comms_recipient
data_type: boolean
description: |
True if the user is a platform comms recipient. False otherwise.
- name: id_user_verification_status
data_type: bigint
description: The ID of the user verification status.
- name: is_test_account
data_type: boolean
description: |
True if the user is a test account. False otherwise.
Note that there might be other users that are test accounts
that are not controlled by this field. However it provides
a first level of filtering.
- name: int_core__vr_check_in_cover
description: "This tables holds information on verification requests
@ -1738,10 +1876,17 @@ models:
tests:
- not_null
- unique
- name: id_account_type
data_type: integer
- name: account_type
data_type: string
description: |
Account type ID. Can be null and might be not up-to-date.
Name of the account type. Can be null and might be not up-to-date.
- name: is_test_account
data_type: boolean
description: |
Flag to identify if the user is a test account.
Can be null and might be not up-to-date. Be aware that
this might not include all test accounts, but it provides
a first level of filtering.
- name: id_billing_country
data_type: integer
description: |