Merged PR 1409: Upgrade Core User

Improve source docs, place tests, adjust a few small details.

There are a few fields that need to be better documented still.
This commit is contained in:
Pablo Martín 2024-03-07 16:24:08 +00:00
commit d5f2a7f9fe
3 changed files with 259 additions and 11 deletions

View file

@ -4,7 +4,168 @@ sources:
- name: core
schema: sync_core
tables:
- name: user
identifier: User
- name: User
description: A User.
columns:
- name: Id
data_type: character varying
quote: True
description: "UUID for the user."
tests:
- unique
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: "^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$"
- name: Code
data_type: bigint
quote: True
description: "WIP. Is this an increment unique ID?"
tests:
- unique
- not_null
- name: Email
data_type: character varying
quote: True
description: "Email for this user."
tests:
- unique
- not_null
- name: Title
data_type: character varying
quote: True
description: ""
- name: DealId
data_type: character varying
quote: True
description: "The Hubspot Deal Id that this user account belongs to. Multiple users can all be part of one Deal."
# This test can't be enforced yet due to some bad test data in the production database. Once that's deal with, this should be activated.
#tests:
# - dbt_expectations.expect_column_values_to_match_regex:
# regex: "^[0-9]{10,11}$"
- name: Deleted
data_type: boolean
quote: True
description: "WIP. I'm guessing this signals that the user wanted to be deleted?"
tests:
- not_null
- name: JoinDate
data_type: timestamp without time zone
quote: True
description: "Timestamp on which the user was created."
tests:
- not_null
- name: LastName
data_type: character varying
quote: True
description: ""
- name: UserName
data_type: character varying
quote: True
description: ""
tests:
- not_null
- name: FirstName
data_type: character varying
quote: True
description: ""
- name: CodePrefix
data_type: character varying
quote: True
description: "WIP. No clue on what is this."
- name: BillingTown
data_type: character varying
quote: True
description: ""
- name: CompanyName
data_type: character varying
quote: True
description: ""
- name: DateOfBirth
data_type: timestamp without time zone
quote: True
description: ""
- name: PhoneNumber
data_type: character varying
quote: True
description: ""
- name: PasswordHash
data_type: character varying
quote: True
description: ""
- name: AccountTypeId
data_type: bigint
quote: True
description: ""
- name: CreatedUserId
data_type: character varying
quote: True
description: |
A user can be created by another user. If this user has been created by another user, this is the UUID of the creator.
Else, this is null.
tests:
- dbt_expectations.expect_column_values_to_match_regex:
regex: "^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$"
row_condition: '"CreatedUserId" is not null'
- name: SecurityStamp
data_type: character varying
quote: True
description: "WIP. I have no clue what this is."
- name: EmailConfirmed
data_type: boolean
quote: True
description: "WIP. I have no clue what this is."
- name: LockoutEnabled
data_type: boolean
quote: True
description: "WIP. I have no clue what this is."
- name: BillingPostCode
data_type: character varying
quote: True
description: ""
- name: BillingCountryId
data_type: bigint
quote: True
description: ""
- name: TwoFactorEnabled
data_type: boolean
quote: True
description: ""
- name: AccessFailedCount
data_type: bigint
quote: True
description: ""
- name: LockoutEndDateUtc
data_type: timestamp without time zone
quote: True
description: "WIP. I have no clue what this is"
- name: BillingAddressLine1
data_type: character varing
quote: True
description: ""
- name: BillingAddressLine2
data_type: character varying
quote: True
description: ""
- name: PhoneNumberConfirmed
data_type: boolean
quote: True
description: ""
tests:
- not_null
- name: _airbyte_raw_id
data_type: character varying
description: "{{ doc('_airbyte_raw_id_desc') }}"
- name: _airbyte_extracted_at
data_type: timestamp with time zone
description: "{{ doc('_airbyte_extracted_at_desc') }}"
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 2
- name: _airbyte_meta
data_type: jsonb
description: "{{ doc('_airbyte_meta_desc') }}"
- name: superhog_user
identifier: SuperhogUser

View file

@ -1,15 +1,102 @@
version: 2
models:
- name: stg_core_user
- name: stg_core__user
description: "The staging version of Core's User table. Do not confuse with SuperhogUser."
columns:
- name: id_user
description: "The primary key for this table"
tests:
- unique
- not_null
data_type: character varying
description: "UUID for the user."
- name: user_code
data_type: bigint
description: "WIP. Is this an increment unique ID?"
- name: email
data_type: character varying
description: "Email for this user."
- name: title
data_type: character varying
description: ""
- name: id_deal
data_type: character varying
description: "The Hubspot Deal Id that this user account belongs to. Multiple users can all be part of one Deal."
- name: is_deleted
data_type: boolean
description: "WIP. I'm guessing this signals that the user wanted to be deleted?"
- name: join_date_utc
data_type: timestamp without time zone
description: "Timestamp on which the user was created."
- name: last_name
data_type: character varying
description: ""
- name: user_name
data_type: character varying
description: ""
- name: first_name
data_type: character varying
description: ""
- name: code_prefix
data_type: character varying
description: "WIP. No clue on what is this."
- name: billing_town
data_type: character varying
description: ""
- name: company_name
data_type: character varying
description: ""
- name: date_of_birth
data_type: date
description: ""
- name: phone_number
data_type: character varying
description: ""
- name: password_hash
data_type: character varying
description: ""
- name: id_account_type
data_type: bigint
description: ""
- name: id_created_user
data_type: character varying
description: |
A user can be created by another user. If this user has been created by another user, this is the UUID of the creator.
Else, this is null.
- name: security_stamp
data_type: character varying
description: "WIP. I have no clue what this is."
- name: is_email_confirmed
data_type: boolean
description: "WIP. I have no clue what this is."
- name: is_lockout_enabled
data_type: boolean
description: "WIP. I have no clue what this is."
- name: billing_postcode
data_type: character varying
description: ""
- name: id_billing_country
data_type: bigint
description: ""
- name: is_twofactor_enabled
data_type: boolean
description: ""
- name: access_failed_count
data_type: bigint
description: ""
- name: lockout_end_date_utc
data_type: timestamp without time zone
description: "WIP. I have no clue what this is"
- name: billing_address_line_1
data_type: character varing
description: ""
- name: billing_address_line_2
data_type: character varying
description: ""
- name: is_phone_number_confirmed
data_type: boolean
description: ""
- name: dwh_extracted_date_utc
data_type: date
description: "{{ doc('dwh_extracted_date_utc_desc')}}"
- name: stg_core_superhog_user
description: "The staging version of Core's SuperhogUser table. Do not confuse with User."

View file

@ -1,5 +1,5 @@
with
raw_user as (select * from {{ source("core", "user") }}),
raw_user as (select * from {{ source("core", "User") }}),
stg_core__user as (
select
{{ adapter.quote("Id") }} as id_user,
@ -15,7 +15,7 @@ with
{{ adapter.quote("CodePrefix") }} as code_prefix,
{{ adapter.quote("BillingTown") }} as billing_town,
{{ adapter.quote("CompanyName") }} as company_name,
{{ adapter.quote("DateOfBirth") }} as date_of_birth,
cast({{ adapter.quote("DateOfBirth") }} as date) as date_of_birth,
{{ adapter.quote("PhoneNumber") }} as phone_number,
{{ adapter.quote("PasswordHash") }} as password_hash,
{{ adapter.quote("AccountTypeId") }} as id_account_type,