Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 108 additions & 19 deletions models/intermediate/Employees/_int_employees_models.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,68 @@


version: 2
models:

#=========================================================================================
#================================ Models : int_employee_profile ==========================
#=========================================================================================
- name: int_employee_profile
description: |
**Model Purpose:**
Creates a trusted employee profile dataset by isolating, tokenizing, and standardizing
core identity and onboarding configurations from raw employee records. The model resolves
critical data quality issues by programmatically decomposing unified full name blocks into
discrete name components (`first_name`, `last_name`) and parsing highly fragmented string
inputs into deterministic, ISO-compliant calendar dates. The resulting dataset establishes
a high-integrity foundation for workforce demographics, accurate identity tracking,
headcount timelines, and downstream dimensional modeling.

columns:
- name: employee_id
description: |
Primary key of the employee profile dimension. Inherited from the staging infrastructure
and validated for row uniqueness.
tests:
- unique
- not_null

- name: first_name
description: |
The isolated given name of the employee.
**Transformation Logic:** Calculated using a structural string metric. It counts the whitespace
delimiters within the raw name block. If exactly one space is present (representing a standard
two-part name structure), it translates spaces to dots and leverages the system `PARSENAME` object
metadata parser to pull the second segment from the right.
tests:
- not_null

- name: last_name
description: |
The isolated family name or surname of the employee.
**Transformation Logic:** Programmatically extracts the absolute right-most token from the
`full_name` field by splitting on whitespace components. This field is guaranteed to populate
regardless of whether the employee has a middle initial or complex prefix.
tests:
- not_null

- name: hire_date
description: |
The canonical calendar date marking the employee's formal onboarding into the enterprise network.
**Transformation Logic:** Converts multiple incoming text-based date patterns into an immutable
ISO-standard `DATE` (YYYY-MM-DD) format using an explicit `CASE` branching ladder:
- Textual month names (e.g., 'January 15, 2021') and standard hyphen/slash formats
(e.g., 'YYYY-MM-DD') are parsed via native conversion.
- Regional date ambiguity is resolved dynamically: if the leading numerical segment exceeds 12,
it is cast via International conventions (Styles 103/105); if the middle segment exceeds 12,
it is treated as a US convention (Styles 101/110).
- Any unmapped or non-standard variations safely fallback onto a standard casting function
to maintain temporal tracking integrity.
tests:
- not_null

#=========================================================================================
#============================= Models : int_employee_employment ==========================
#=========================================================================================
version: 2
models:
- name: int_employee_employment
description: |
Creates a trusted employee employment dataset by standardizing organizational
Expand Down Expand Up @@ -41,19 +99,11 @@ models:
- Sales Manager
- Sales Representative
- Senior Sales Associate
- Store Manager Account Executive
- Customer Advisor
- Regional Manager
- Sales Associate
- Sales Consultant
- Sales Manager
- Sales Representative
- Senior Sales Associate
- Store Manager
- Store Manager

- name: department
description: |
The standardized corporate department classification (e.g., Sales, Operations).
The standardized corporate department classification (e.g., Sales, Operations etc..).
**Transformation Logic:** Implements defensive string trimming and converts missing/null/blank
values to `'Unknown'`. This column provides a bulletproof aggregation path for departmental
headcount and cost center distribution analysis.
Expand All @@ -66,6 +116,7 @@ models:
- Management
- Operations
- Sales
- Unknown

- name: store_id
description: |
Expand Down Expand Up @@ -116,12 +167,8 @@ models:
The normalized performance evaluation bucket resulting from the employee's latest review cycle.
**Transformation Logic:** Resolves massive legacy data fragmentation. It interprets a mixed-type
input vector containing numbers (`5`, `4`, `3`, `2`), letter grades (`A`, `B`, `C`, `D`), and
untrimmed text descriptions, mapping them into a clean 4-tier categorical dimension:
- *'Excellent'* (Maps from: 'excellent', 'a', '5')
- *'Good'* (Maps from: 'good', 'b', '4')
- *'Average'* (Maps from: 'average', 'c', '3')
- *'Below Average'* (Maps from: 'below average', 'd', '2')
- Any missing, blank, or unmapped value default securely to *'Unknown'*.
untrimmed text descriptions, mapping them into a clean 4-tier categorical dimension
(example :'Excellent', 'Good', 'Average', 'Below Average', 'Unknown' )
tests:
- accepted_values:
arguments:
Expand Down Expand Up @@ -152,4 +199,46 @@ models:
- not_null
- accepted_values:
arguments:
values: ['True', 'False']
values: ['True', 'False']

#=========================================================================================
#================================ Models : int_employee_contact ==========================
#=========================================================================================
- name: int_employee_contact
description: |
Creates a trusted employee contact dataset by improving the quality and
consistency of employee communication attributes. The model validates and
repairs email addresses and standardizes phone numbers into a common format.
The resulting dataset provides reliable contact information for internal
communications, identity matching, corporate directory services, and downstream
analytical models.

columns:
- name: employee_id
description: |
Primary key of the employee contact dimension. Inherited from the
staging layer and used to uniquely identify individual resource records.
tests:
- unique
- not_null

- name: email
description: |
The standardized corporate or personal email address of the employee.
**Transformation Logic:** Implements programmatic cleansing to resolve formatting anomalies:
- Null or empty strings, as well as entries completely missing the '@' delimiter, are forced to 'Unknown'.
- Structural duplication issues (e.g., multiple '@' signs) are resolved by isolating the first instance and stripping duplicate characters from the domain string.
- All valid entries are trimmed and cast to lowercase to maintain strict grouping consistency.
tests:
- not_null

- name: phone
description: |
The employee's phone number standardized into the corporate '+1 (XXX) XXX-XXXX' format.
**Transformation Logic:** Evaluates incoming string patterns against five distinct structural signatures to re-align components uniformly:
- Formats starting with a plus sign and an international code (e.g., '+1XXXXXXXXXX') are parsed and injected with standard spaces, brackets, and hyphens.
- Dotted strings ('XXX.XXX.XXXX') or continuous digit sequences ('XXXXXXXXXX') are sliced into area code, prefix, and line number groups before concatenation.
- Hyphen-separated values ('XXX-XXX-XXXX') are combined directly by preserving the tail positions.
- Already formatted parenthesized elements ('(XXX) XXX-XXXX') are prepended with the standard international country indicator '+1 '.
tests:
- not_null
148 changes: 148 additions & 0 deletions models/intermediate/Inventory/_int_inventory_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
version: 2

models:
####################################################################################
####################### Model: int_inventory_product ###############################
####################################################################################
- name: int_inventory_product
description: |
Creates a trusted product tracking dataset by standardizing snapshot logging dates,
cleaning product identifiers, and resolving textual categorization anomalies across
inventory snapshots. The model handles regional variations in string-based date configurations
and maps product categories into a standardized, clean taxonomy. The resulting dataset
provides a consistent product grain for operational inventory control and downstream reporting.

columns:
- name: inventory_snapshot_sk
description: Surrogate primary key uniquely identifying a specific product item log during a snapshot period.
tests:
- unique
- not_null

- name: snapshot_date
description: |
The standardized calendar logging date for inventory item records.
**Transformation Logic:** Implements an explicit CASE validation ladder to parse text-based dates into an ISO-standard DATE format:
- Textual or abbreviated months and standard hyphen/slash paths (YYYY-MM-DD or YYYY/MM/DD) are natively converted.
- Multi-locale string structures are evaluated dynamically: if the middle token is greater than 12, it handles it as a US format (Style 101 or 110);
if the leading token is greater than 12, it is routed via International styles (Style 103 or 105).
tests:
- not_null

- name: product_id
description: |
The validated operational identifier for the product. Un-castable alphanumeric strings
or missing values are safely coerced to NULL to prevent downstream join failures.
tests:
- not_null

- name: product_name
description: |
Official product nomenclature. Leading and trailing whitespaces are removed via trimming,
with missing or blank values defaulting to 'Unknown'.
tests:
- not_null

- name: sku
description: |
Stock Keeping Unit alpha-numeric tracking string. Whitespace components are trimmed
and missing or empty records resolve to 'Unknown'.
tests:
- not_null

- name: category
description: |
Standardized product line categorization. Maps varied lowercase or messy textual entries into
10 business-defined Title Case operational paths: 'Electronics', 'Clothing', 'Kitchen', 'Office',
'Sports', 'Health', 'Beauty', 'Footwear', 'Toys', or 'Bags'. Unmatched configurations resolve to 'Unknown'.
tests:
- not_null
- accepted_values:
arguments:
values: ['Electronics', 'Clothing', 'Kitchen', 'Office', 'Sports', 'Health', 'Beauty', 'Footwear', 'Toys', 'Bags', 'Unknown']

####################################################################################
####################### Model: int_inventory_stock #################################
####################################################################################
- name: int_inventory_stock
description: |
Calculates key physical unit availability metrics across inventory snapshots by enforcing
numeric boundaries. The model validates system counts, filters out impossible negative numbers,
and computes real-time pickable availability balances to provide an accurate picture of net warehouse stock.

columns:
- name: inventory_snapshot_sk
description: Surrogate primary key identifying the unique item snapshot sequence.
tests:
- unique
- not_null

- name: stock_on_hand
description: |
The total recorded physical item count present inside the warehouse facility.
Alphanumeric parsing anomalies or negative value errors are explicitly set to NULL.

- name: stock_reserved
description: |
The count of units allocated or committed to active customer orders.
Negative entries or invalid numeric data strings are coerced to NULL.

- name: stock_available
description: |
The net quantity of items currently pickable, sellable, and uncommitted.
**Transformation Logic:** Dynamically calculated inline as `stock_on_hand` minus `stock_reserved`.

- name: reorder_level
description: |
The replenishment baseline safety milestone count. Values failing integer conversion
or registering below zero are converted to NULL.

####################################################################################
####################### Model: int_inventory_valuation #############################
####################################################################################
- name: int_inventory_valuation
description: |
Enriches snapshot files with high-precision asset valuation and pricing metrics. The model
strips formatting noise (such as currency symbols and comma grouping separators) from text fields,
standardizes locations, and calculates extended inventory holding values for financial and margin analysis.

columns:
- name: inventory_snapshot_sk
description: Surrogate primary key identifying the evaluated warehouse ledger item.
tests:
- unique
- not_null

- name: unit_cost
description: |
The acquisition cost per unit cast to a decimal(10,2) format for exact precision.
**Transformation Logic:** Programmatically checks for and strips leading '$' markers from text strings before conversion.

- name: unit_price
description: |
The Manufacturer's Suggested Retail Price (MSRP) for the item, cast to a decimal(10,2) format.
**Transformation Logic:** Cleanses text strings by stripping out both currency '$' characters
and embedded thousands comma groupings (',') to allow safe mathematical execution.

- name: stock_on_hand
description: |
The physical count of units present in the warehouse. Non-numeric inputs or negative counts
resolve to NULL to protect downstream multiplication.

- name: inventory_value
description: |
The extended total dollar value of the stock on hand.
**Transformation Logic:** Evaluated dynamically by multiplying the cleaned `unit_price`
by the validated `stock_on_hand`.

- name: warehouse_location
description: |
The tracking designation code for the storage facility. Values are standardized to UPPERCASE
with missing or blank fields defaulting to 'Unknown'.
tests:
- not_null

- name: store_id
description: |
The associated brick-and-mortar retail location identifier. Converted to an integer data type,
with missing or blank spaces coerced to NULL.
Loading
Loading