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
6 changes: 4 additions & 2 deletions models/intermediate/Employees/_int_employees_models.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


version: 2
models:

Expand Down Expand Up @@ -125,6 +123,10 @@ models:
the source value into a standard `INT`. If the raw entry is non-numeric (fails parsing) OR
is a negative integer (physically impossible for our enterprise sequence), the model coerces
the result to `NULL`. This completely eliminates downstream foreign key join failures.
tests:
- relationships:
to: ref('int_store_profile')
field: store_id

- name: store_name
description: |
Expand Down
3 changes: 3 additions & 0 deletions models/intermediate/Inventory/_int_inventory_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ models:
or missing values are safely coerced to NULL to prevent downstream join failures.
tests:
- not_null
- relationships:
to: ref('int_product_attributes')
field: product_id

- name: product_name
description: |
Expand Down
150 changes: 150 additions & 0 deletions models/intermediate/Returns/_int_returns_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
version: 2

models:
####################################################################################
####################### Model: int_return_processing ###############################
####################################################################################
- name: int_return_processing
description: |
Creates a trusted return processing operational dataset by standardizing categorical metrics,
normalizing return fulfillment channels, and cleansing workflow status identifiers. The model
applies Title Case to reason fields and handles alphanumeric casting exceptions for logistics personnel.

columns:
- name: return_id
description: Primary key uniquely identifying the individual return log.
tests:
- unique
- not_null

- name: return_reason
description: |
The documented customer reason for returning the product.
**Transformation Logic:** Standardized using whitespace trimming and converted to Title Case. Missing or empty string inputs fallback to 'Unknown'.
tests:
- not_null

- name: return_channel
description: |
The operational channel through which the return was initiated.
**Transformation Logic:** Groups highly fragmented text inputs into specific corporate categories:
- 'Mobile App' (Mapped from: 'app', 'mobile app', 'mobile')
- 'In Store' (Mapped from: 'in store', 'in-store', 'store')
- 'Online' (Mapped from: 'online', 'web')
- 'Phone Call' (Mapped from: 'phone')
- 'Catalog' (Mapped from: 'catalog')
- Unmapped formats default to 'Unknown'.
tests:
- not_null
- accepted_values:
arguments:
values: ['Mobile App', 'In Store', 'Online', 'Phone Call', 'Catalog', 'Unknown']

- name: restocked
description: |
Operational flag indicating whether the item was returned to store inventory shelf space.
**Transformation Logic:** Standardized from multi-type strings ('yes', 'y', '1' to 'Yes' / 'no', 'n', '0' to 'No'). Outliers resolve to 'Unknown'.
tests:
- not_null
- accepted_values:
arguments:
values: ['Yes', 'No', 'Unknown']

- name: return_status
description: |
Current state of the return processing lifecycle. Standardized to Title Case; missing source entries default to 'Unknown'.
tests:
- not_null

- name: handled_by_emp_id
description: |
The unique identifier of the store employee processing the return ticket. Converted to an integer data type, with missing or invalid fields coerced to NULL.

####################################################################################
####################### Model: int_return_refund ###################################
####################################################################################
- name: int_return_refund
description: |
Extracts and sanitizes financial reimbursement attributes for returned orders. The model programmatically
scrubs text currency strings to isolate decimals and normalizes payment methods to support precise gross margin
reconciliation tracking.

columns:
- name: return_id
description: Unique primary key mapping to the corresponding return entry.
tests:
- unique
- not_null

- name: refund_amount
description: |
The total dollar value reimbursed back to the customer, cast to decimal(10,2) precision.
**Transformation Logic:** Strips formatting artifacts including currency symbols ('$') and thousands separators (',') before typecasting. Negative entries or un-castable formats default to NULL.

- name: refund_method
description: |
The transaction payment type used for the reimbursement (e.g., Credit Card, Cash). Standardized using Title Case, defaulting blank rows to 'Unknown'.
tests:
- not_null
- accepted_values:
arguments:
values:
- Cash
- Original Payment
- Store Credit

####################################################################################
####################### Model: int_return_transaction ##############################
####################################################################################
- name: int_return_transaction
description: |
Normalizes and links return vouchers back to their core original transaction entities. The model enforces
prefix patterns for tracking codes, tokenizes associated consumer profile fields into Title Case, and
executes a multi-locale temporal handling sequence to cast multi-format text values into clean ISO dates.

columns:
- name: return_id
description: Cleaned primary identification key. Values below 1 or non-numeric elements resolve to NULL.
tests:
- unique
- not_null

- name: original_txn_id
description: |
The alphanumeric string of the original purchasing transaction header.
**Transformation Logic:** Enforces strict systemic syntax verification: must contain the
corporate prefix 'TXN-' and maintain a minimum character length of 10. Failing rows are coerced to NULL.

- name: original_order_id
description: The integer identifier tracking the master order entry. Values below 1 or invalid formats resolve to NULL.

- name: customer_id
description: Unique identifier linking the transaction to a customer account profile. Invalid formats resolve to NULL.

- name: customer_name
description: Full name of the purchasing client. Standardized into Title Case; blank inputs fallback to 'Unknown'.
tests:
- not_null

- name: product_id
description: Unique identifier tracking the specific physical item returned. Invalid formats resolve to NULL.

- name: product_name
description: Official description name of the item. Standardized into Title Case; blanks default to 'Unknown'.
tests:
- not_null

- name: quantity_returned
description: |
Total count of physical units returned. Enforces business rule threshold :
values below 1 or non-numeric elements are coerced to NULL.

- name: return_date
description: |
The calendar date the return was officially recorded by the system.
**Transformation Logic:** Evaluates multiple text structures into an ISO-standard DATE format via an explicit CASE validation tree:
- Textual month lines and standard hyphen/slash paths are natively parsed.
- Multi-locale ambiguity is handled defensively: if the middle token exceeds 12, it is treated as US format (Style 101);
if the leading segment exceeds 12, it is handled as International format (Style 103).
tests:
- not_null
122 changes: 122 additions & 0 deletions models/intermediate/Reviews/_int_reviews_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
version: 2

models:
####################################################################################
####################### Model: int_review_feedback #################################
####################################################################################
- name: int_review_feedback
description: |
Creates a trusted product review metadata dataset by standardizing submission channels
and cleansing text field values. The model normalizes user engagement attributes,
strips carriage returns and line breaks from titles using scalar operations, and maps
highly fragmented input strings into canonical omni-channel tracking vectors.

columns:
- name: review_id
description: Primary key uniquely identifying the consumer review record.
tests:
- unique
- not_null

- name: helpful_votes
description: The total volume of user votes marking the review as informative.

- name: review_channel
description: |
The unified front-end channel where the submission was published.
**Transformation Logic:** Groups variations and shortcuts into a Title Case business taxonomy:
- 'Mobile App' (From: 'app', 'mobile app', 'mobile')
- 'In Store' (From: 'in store', 'in-store', 'store')
- 'Online' (From: 'online', 'web')
- 'Phone Call' (From: 'phone')
- 'Catalog' (From: 'catalog')
- Missing or unmapped structures safely default to 'Unknown'.
tests:
- not_null
- accepted_values:
arguments:
values: ['Mobile App', 'In Store', 'Online', 'Phone Call', 'Catalog', 'Unknown']

- name: review_title
description: |
The sanitized summary title text.
**Transformation Logic:** Applies whitespace trimming, Title Case conversions, and strips
hidden carriage returns `CHAR(13)` and line feeds `CHAR(10)`. Empty fields default to 'Unknown'.
tests:
- not_null

####################################################################################
####################### Model: int_review_rating ###################################
####################################################################################
- name: int_review_rating
description: |
Processes customer review scores by implementing defensive type-casting and explicit boundary validation.
The model protects downstream aggregate scoring matrices (such as Average Rating Score) by
filtering out out-of-bounds ratings and corrupted text responses.

columns:
- name: review_id
description: Primary key matching back to the master feedback dimension.
tests:
- unique
- not_null

- name: rating
description: |
The validated numerical assessment score assigned by the consumer.
**Transformation Logic:** Casts the source string to an integer. Enforces a strict business boundary:
values MUST sit between 1 and 5 inclusive. Any values outside this target scale default to NULL.
tests:
- accepted_values:
arguments:
values: [1, 2, 3, 4, 5]

- name: rating_text
description: The raw textual comment or contextual feedback submitted along with the rating score.

####################################################################################
####################### Model: int_review_transaction ##############################
####################################################################################
- name: int_review_transaction
description: |
Normalizes and connects product review headers back to their original purchasing transactions,
consumer accounts, and items. The model processes temporal values through a multi-locale validation
ladder to convert multi-format text values into immutable ISO-standard dates.

columns:
- name: review_id
description: Primary key uniquely identifying the review transaction bridge.
tests:
- unique
- not_null

- name: txn_id
description: Foreign key mapping the review back to the source point-of-sale transaction record.
tests:
- not_null

- name: customer_id
description: Foreign key linking to the corresponding customer entity profile.
tests:
- not_null

- name: customer_name
description: The full identity string of the purchasing customer.

- name: product_id
description: Foreign key linking to the corresponding product master record.
tests:
- not_null

- name: product_name
description: Cleaned retail name nomenclature of the item reviewed.

- name: review_date
description: |
The standardized calendar logging date when the review was written.
**Transformation Logic:** Converts multi-format text entries into a safe DATE data type via an explicit CASE validation tree:
- Abbreviated or full textual month variations and standard ISO hyphen/slash paths are natively parsed.
- Date ambiguity is handled defensively: if the middle segment exceeds 12, it is treated as US format (Style 101/110).
If the leading segment exceeds 12, it is handled as International format (Style 103/105).
tests:
- not_null
Loading
Loading