diff --git a/models/staging/core/_core_sources.yml b/models/staging/core/_core_sources.yml index 1157e91..1f8d27a 100644 --- a/models/staging/core/_core_sources.yml +++ b/models/staging/core/_core_sources.yml @@ -263,3 +263,7 @@ sources: identifier: ProductServiceBillingItem - name: VerificationRequestFeatureFlag identifier: VerificationRequestFeatureFlag + - name: ApimUser + identifier: ApimUser + - name: ApimUserType + identifier: ApimUserType diff --git a/models/staging/core/schema.yml b/models/staging/core/schema.yml index e9e1538..4eedba1 100644 --- a/models/staging/core/schema.yml +++ b/models/staging/core/schema.yml @@ -1349,3 +1349,96 @@ models: data_type: timestamp description: | Timestamp of when this Verification Request Feature Flag record was extracted into DWH. + + - name: stg_core__apim_user + description: | + "Contains information about API users. + It includes all users from all different API systems so the data + contained in the json document differs between them." + + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - id_apim_user + - id_apim_user_type + columns: + - name: id_apim_user + data_type: character varying + description: | + Identifier of the User. Acts as the primary key for this table. + Not necessarily unique because the same user can exist in more than + one API system. + tests: + - not_null + + - name: id_apim_user_type + data_type: bigint + description: | + "id of the user type, works as a foreign key to the + apim_user_type table" + tests: + - not_null + + - name: json_document_user_data + data_type: character varying + description: | + "The json document that contains the user information" + + - name: created_at_utc + data_type: timestamp + description: | + Timestamp of when this user was created. + tests: + - not_null + + - name: created_date_utc + data_type: date + description: | + Date of when this user was created. + tests: + - not_null + + - name: updated_at_utc + data_type: timestamp + description: | + Timestamp of when this user was last updated. + tests: + - not_null + + - name: updated_date_utc + data_type: date + description: | + Date of when this user was last updated. + tests: + - not_null + + - name: dwh_extracted_at_utc + data_type: timestamp + description: | + Timestamp of when this record was extracted into DWH. + tests: + - not_null + + - name: stg_core__apim_user_type + description: "" + columns: + - name: id_apim_user_type + data_type: bigint + description: | + Unique identifier of the type of user. Acts as the primary key for this table. + tests: + - unique + - not_null + + - name: user_type_name + data_type: character varying + description: "Name of the user type" + tests: + - unique + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was extracted into DWH. + tests: + - not_null diff --git a/models/staging/core/stg_core__apim_user.sql b/models/staging/core/stg_core__apim_user.sql new file mode 100644 index 0000000..d05df36 --- /dev/null +++ b/models/staging/core/stg_core__apim_user.sql @@ -0,0 +1,17 @@ +with + raw_apim_user as (select * from {{ source("core", "ApimUser") }}), + stg_core__apim_user as ( + select + {{ adapter.quote("UserId") }} as id_apim_user, + {{ adapter.quote("ApimUserTypeId") }} as id_apim_user_type, + {{ adapter.quote("Json") }} as json_document_user_data, + {{ adapter.quote("CreatedDate") }} as created_at_utc, + cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc, + {{ adapter.quote("UpdatedDate") }} as updated_at_utc, + cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc, + {{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc + + from raw_apim_user + ) +select * +from stg_core__apim_user diff --git a/models/staging/core/stg_core__apim_user_type.sql b/models/staging/core/stg_core__apim_user_type.sql new file mode 100644 index 0000000..e5f5c2c --- /dev/null +++ b/models/staging/core/stg_core__apim_user_type.sql @@ -0,0 +1,12 @@ +with + raw_apim_user_type as (select * from {{ source("core", "ApimUserType") }}), + stg_core__apim_user_type as ( + select + {{ adapter.quote("Id") }} as id_apim_user_type, + {{ adapter.quote("Name") }} as user_type_name, + {{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc + + from raw_apim_user_type + ) +select * +from stg_core__apim_user_type