Skip to content

Commit c046657

Browse files
Merge pull request #28 from Ritik574-coder/dbt_branch
adding the document and generic build in test about product , inventory and employees
2 parents ac3dca5 + 818c19c commit c046657

8 files changed

Lines changed: 475 additions & 19 deletions

File tree

models/intermediate/Employees/_int_employees_models.yml

Lines changed: 108 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,68 @@
11

22

3+
version: 2
4+
models:
5+
6+
#=========================================================================================
7+
#================================ Models : int_employee_profile ==========================
8+
#=========================================================================================
9+
- name: int_employee_profile
10+
description: |
11+
**Model Purpose:**
12+
Creates a trusted employee profile dataset by isolating, tokenizing, and standardizing
13+
core identity and onboarding configurations from raw employee records. The model resolves
14+
critical data quality issues by programmatically decomposing unified full name blocks into
15+
discrete name components (`first_name`, `last_name`) and parsing highly fragmented string
16+
inputs into deterministic, ISO-compliant calendar dates. The resulting dataset establishes
17+
a high-integrity foundation for workforce demographics, accurate identity tracking,
18+
headcount timelines, and downstream dimensional modeling.
19+
20+
columns:
21+
- name: employee_id
22+
description: |
23+
Primary key of the employee profile dimension. Inherited from the staging infrastructure
24+
and validated for row uniqueness.
25+
tests:
26+
- unique
27+
- not_null
28+
29+
- name: first_name
30+
description: |
31+
The isolated given name of the employee.
32+
**Transformation Logic:** Calculated using a structural string metric. It counts the whitespace
33+
delimiters within the raw name block. If exactly one space is present (representing a standard
34+
two-part name structure), it translates spaces to dots and leverages the system `PARSENAME` object
35+
metadata parser to pull the second segment from the right.
36+
tests:
37+
- not_null
38+
39+
- name: last_name
40+
description: |
41+
The isolated family name or surname of the employee.
42+
**Transformation Logic:** Programmatically extracts the absolute right-most token from the
43+
`full_name` field by splitting on whitespace components. This field is guaranteed to populate
44+
regardless of whether the employee has a middle initial or complex prefix.
45+
tests:
46+
- not_null
47+
48+
- name: hire_date
49+
description: |
50+
The canonical calendar date marking the employee's formal onboarding into the enterprise network.
51+
**Transformation Logic:** Converts multiple incoming text-based date patterns into an immutable
52+
ISO-standard `DATE` (YYYY-MM-DD) format using an explicit `CASE` branching ladder:
53+
- Textual month names (e.g., 'January 15, 2021') and standard hyphen/slash formats
54+
(e.g., 'YYYY-MM-DD') are parsed via native conversion.
55+
- Regional date ambiguity is resolved dynamically: if the leading numerical segment exceeds 12,
56+
it is cast via International conventions (Styles 103/105); if the middle segment exceeds 12,
57+
it is treated as a US convention (Styles 101/110).
58+
- Any unmapped or non-standard variations safely fallback onto a standard casting function
59+
to maintain temporal tracking integrity.
60+
tests:
61+
- not_null
62+
363
#=========================================================================================
464
#============================= Models : int_employee_employment ==========================
565
#=========================================================================================
6-
version: 2
7-
models:
866
- name: int_employee_employment
967
description: |
1068
Creates a trusted employee employment dataset by standardizing organizational
@@ -41,19 +99,11 @@ models:
4199
- Sales Manager
42100
- Sales Representative
43101
- Senior Sales Associate
44-
- Store Manager Account Executive
45-
- Customer Advisor
46-
- Regional Manager
47-
- Sales Associate
48-
- Sales Consultant
49-
- Sales Manager
50-
- Sales Representative
51-
- Senior Sales Associate
52-
- Store Manager
102+
- Store Manager
53103

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

70121
- name: store_id
71122
description: |
@@ -116,12 +167,8 @@ models:
116167
The normalized performance evaluation bucket resulting from the employee's latest review cycle.
117168
**Transformation Logic:** Resolves massive legacy data fragmentation. It interprets a mixed-type
118169
input vector containing numbers (`5`, `4`, `3`, `2`), letter grades (`A`, `B`, `C`, `D`), and
119-
untrimmed text descriptions, mapping them into a clean 4-tier categorical dimension:
120-
- *'Excellent'* (Maps from: 'excellent', 'a', '5')
121-
- *'Good'* (Maps from: 'good', 'b', '4')
122-
- *'Average'* (Maps from: 'average', 'c', '3')
123-
- *'Below Average'* (Maps from: 'below average', 'd', '2')
124-
- Any missing, blank, or unmapped value default securely to *'Unknown'*.
170+
untrimmed text descriptions, mapping them into a clean 4-tier categorical dimension
171+
(example :'Excellent', 'Good', 'Average', 'Below Average', 'Unknown' )
125172
tests:
126173
- accepted_values:
127174
arguments:
@@ -152,4 +199,46 @@ models:
152199
- not_null
153200
- accepted_values:
154201
arguments:
155-
values: ['True', 'False']
202+
values: ['True', 'False']
203+
204+
#=========================================================================================
205+
#================================ Models : int_employee_contact ==========================
206+
#=========================================================================================
207+
- name: int_employee_contact
208+
description: |
209+
Creates a trusted employee contact dataset by improving the quality and
210+
consistency of employee communication attributes. The model validates and
211+
repairs email addresses and standardizes phone numbers into a common format.
212+
The resulting dataset provides reliable contact information for internal
213+
communications, identity matching, corporate directory services, and downstream
214+
analytical models.
215+
216+
columns:
217+
- name: employee_id
218+
description: |
219+
Primary key of the employee contact dimension. Inherited from the
220+
staging layer and used to uniquely identify individual resource records.
221+
tests:
222+
- unique
223+
- not_null
224+
225+
- name: email
226+
description: |
227+
The standardized corporate or personal email address of the employee.
228+
**Transformation Logic:** Implements programmatic cleansing to resolve formatting anomalies:
229+
- Null or empty strings, as well as entries completely missing the '@' delimiter, are forced to 'Unknown'.
230+
- Structural duplication issues (e.g., multiple '@' signs) are resolved by isolating the first instance and stripping duplicate characters from the domain string.
231+
- All valid entries are trimmed and cast to lowercase to maintain strict grouping consistency.
232+
tests:
233+
- not_null
234+
235+
- name: phone
236+
description: |
237+
The employee's phone number standardized into the corporate '+1 (XXX) XXX-XXXX' format.
238+
**Transformation Logic:** Evaluates incoming string patterns against five distinct structural signatures to re-align components uniformly:
239+
- Formats starting with a plus sign and an international code (e.g., '+1XXXXXXXXXX') are parsed and injected with standard spaces, brackets, and hyphens.
240+
- Dotted strings ('XXX.XXX.XXXX') or continuous digit sequences ('XXXXXXXXXX') are sliced into area code, prefix, and line number groups before concatenation.
241+
- Hyphen-separated values ('XXX-XXX-XXXX') are combined directly by preserving the tail positions.
242+
- Already formatted parenthesized elements ('(XXX) XXX-XXXX') are prepended with the standard international country indicator '+1 '.
243+
tests:
244+
- not_null

models/intermediate/Employees/int_employees_contact.sql renamed to models/intermediate/Employees/int_employee_contact.sql

File renamed without changes.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
version: 2
2+
3+
models:
4+
####################################################################################
5+
####################### Model: int_inventory_product ###############################
6+
####################################################################################
7+
- name: int_inventory_product
8+
description: |
9+
Creates a trusted product tracking dataset by standardizing snapshot logging dates,
10+
cleaning product identifiers, and resolving textual categorization anomalies across
11+
inventory snapshots. The model handles regional variations in string-based date configurations
12+
and maps product categories into a standardized, clean taxonomy. The resulting dataset
13+
provides a consistent product grain for operational inventory control and downstream reporting.
14+
15+
columns:
16+
- name: inventory_snapshot_sk
17+
description: Surrogate primary key uniquely identifying a specific product item log during a snapshot period.
18+
tests:
19+
- unique
20+
- not_null
21+
22+
- name: snapshot_date
23+
description: |
24+
The standardized calendar logging date for inventory item records.
25+
**Transformation Logic:** Implements an explicit CASE validation ladder to parse text-based dates into an ISO-standard DATE format:
26+
- Textual or abbreviated months and standard hyphen/slash paths (YYYY-MM-DD or YYYY/MM/DD) are natively converted.
27+
- 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);
28+
if the leading token is greater than 12, it is routed via International styles (Style 103 or 105).
29+
tests:
30+
- not_null
31+
32+
- name: product_id
33+
description: |
34+
The validated operational identifier for the product. Un-castable alphanumeric strings
35+
or missing values are safely coerced to NULL to prevent downstream join failures.
36+
tests:
37+
- not_null
38+
39+
- name: product_name
40+
description: |
41+
Official product nomenclature. Leading and trailing whitespaces are removed via trimming,
42+
with missing or blank values defaulting to 'Unknown'.
43+
tests:
44+
- not_null
45+
46+
- name: sku
47+
description: |
48+
Stock Keeping Unit alpha-numeric tracking string. Whitespace components are trimmed
49+
and missing or empty records resolve to 'Unknown'.
50+
tests:
51+
- not_null
52+
53+
- name: category
54+
description: |
55+
Standardized product line categorization. Maps varied lowercase or messy textual entries into
56+
10 business-defined Title Case operational paths: 'Electronics', 'Clothing', 'Kitchen', 'Office',
57+
'Sports', 'Health', 'Beauty', 'Footwear', 'Toys', or 'Bags'. Unmatched configurations resolve to 'Unknown'.
58+
tests:
59+
- not_null
60+
- accepted_values:
61+
arguments:
62+
values: ['Electronics', 'Clothing', 'Kitchen', 'Office', 'Sports', 'Health', 'Beauty', 'Footwear', 'Toys', 'Bags', 'Unknown']
63+
64+
####################################################################################
65+
####################### Model: int_inventory_stock #################################
66+
####################################################################################
67+
- name: int_inventory_stock
68+
description: |
69+
Calculates key physical unit availability metrics across inventory snapshots by enforcing
70+
numeric boundaries. The model validates system counts, filters out impossible negative numbers,
71+
and computes real-time pickable availability balances to provide an accurate picture of net warehouse stock.
72+
73+
columns:
74+
- name: inventory_snapshot_sk
75+
description: Surrogate primary key identifying the unique item snapshot sequence.
76+
tests:
77+
- unique
78+
- not_null
79+
80+
- name: stock_on_hand
81+
description: |
82+
The total recorded physical item count present inside the warehouse facility.
83+
Alphanumeric parsing anomalies or negative value errors are explicitly set to NULL.
84+
85+
- name: stock_reserved
86+
description: |
87+
The count of units allocated or committed to active customer orders.
88+
Negative entries or invalid numeric data strings are coerced to NULL.
89+
90+
- name: stock_available
91+
description: |
92+
The net quantity of items currently pickable, sellable, and uncommitted.
93+
**Transformation Logic:** Dynamically calculated inline as `stock_on_hand` minus `stock_reserved`.
94+
95+
- name: reorder_level
96+
description: |
97+
The replenishment baseline safety milestone count. Values failing integer conversion
98+
or registering below zero are converted to NULL.
99+
100+
####################################################################################
101+
####################### Model: int_inventory_valuation #############################
102+
####################################################################################
103+
- name: int_inventory_valuation
104+
description: |
105+
Enriches snapshot files with high-precision asset valuation and pricing metrics. The model
106+
strips formatting noise (such as currency symbols and comma grouping separators) from text fields,
107+
standardizes locations, and calculates extended inventory holding values for financial and margin analysis.
108+
109+
columns:
110+
- name: inventory_snapshot_sk
111+
description: Surrogate primary key identifying the evaluated warehouse ledger item.
112+
tests:
113+
- unique
114+
- not_null
115+
116+
- name: unit_cost
117+
description: |
118+
The acquisition cost per unit cast to a decimal(10,2) format for exact precision.
119+
**Transformation Logic:** Programmatically checks for and strips leading '$' markers from text strings before conversion.
120+
121+
- name: unit_price
122+
description: |
123+
The Manufacturer's Suggested Retail Price (MSRP) for the item, cast to a decimal(10,2) format.
124+
**Transformation Logic:** Cleanses text strings by stripping out both currency '$' characters
125+
and embedded thousands comma groupings (',') to allow safe mathematical execution.
126+
127+
- name: stock_on_hand
128+
description: |
129+
The physical count of units present in the warehouse. Non-numeric inputs or negative counts
130+
resolve to NULL to protect downstream multiplication.
131+
132+
- name: inventory_value
133+
description: |
134+
The extended total dollar value of the stock on hand.
135+
**Transformation Logic:** Evaluated dynamically by multiplying the cleaned `unit_price`
136+
by the validated `stock_on_hand`.
137+
138+
- name: warehouse_location
139+
description: |
140+
The tracking designation code for the storage facility. Values are standardized to UPPERCASE
141+
with missing or blank fields defaulting to 'Unknown'.
142+
tests:
143+
- not_null
144+
145+
- name: store_id
146+
description: |
147+
The associated brick-and-mortar retail location identifier. Converted to an integer data type,
148+
with missing or blank spaces coerced to NULL.

0 commit comments

Comments
 (0)