Skip to content

Commit 6d7f220

Browse files
update : adding the intermidate custoemr document and test
1 parent e0bedbb commit 6d7f220

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

dbt_project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require-dbt-version: [">=1.8.0", "<2.0.0"]
88

99
flags:
1010
dbt_sqlserver_use_native_string_types: true
11+
dbt_sqlserver_use_default_schema_concat: true
1112

1213
model-paths: ["models"]
1314
analysis-paths: ["analyses"]

models/intermediate/Customers/int_customer_location.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ SELECT
4242
ELSE TRIM(UPPER(state_abbr))
4343
END as state_abbr,
4444

45+
CASE
46+
WHEN TRIM(state_full) IS NULL OR TRIM(state_full) = '' THEN 'Unknown'
47+
ELSE TRIM(state_full)
48+
END AS state,
49+
4550
CASE
4651
WHEN zip_code IS NULL THEN 0
4752
WHEN LEN(zip_code) != 5 THEN 0
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: 2
2+
3+
models:
4+
- name: int_customer_location
5+
description: |
6+
Cleans and standardizes customer geographic information for downstream
7+
analytical models. This model resolves common data quality issues such as
8+
missing values, inconsistent capitalization, typographical errors in city
9+
names, invalid state abbreviations, malformed ZIP codes, and inconsistent
10+
country values. It provides a reliable and consistent customer location
11+
dimension for business reporting and analytics.
12+
13+
columns:
14+
- name: customer_id
15+
description: |
16+
Unique identifier for each customer. Used as the primary key for
17+
customer location records.
18+
tests:
19+
- not_null
20+
- unique
21+
22+
- name: address
23+
description: |
24+
Standardized customer street address. Missing or blank values are
25+
replaced with 'Unknown', while valid addresses are converted to
26+
Title Case and trimmed of leading and trailing whitespace.
27+
tests:
28+
- not_null
29+
30+
- name: city
31+
description: |
32+
Standardized customer city name. Common spelling mistakes are corrected,
33+
text is converted to Title Case, and missing or blank values are
34+
replaced with 'Unknown'.
35+
tests:
36+
- not_null
37+
38+
- name: state_abbr
39+
description: |
40+
Two-letter uppercase state abbreviation. Invalid, blank, null, or
41+
incorrectly formatted values are replaced with 'Unknown'.
42+
tests:
43+
- not_null
44+
45+
- name: state
46+
description: |
47+
Full state name for the customer's location. Leading and trailing
48+
whitespace is removed, and missing or blank values are replaced
49+
with 'Unknown'.
50+
tests:
51+
- not_null
52+
53+
- name: zip_code
54+
description: |
55+
Five-digit ZIP code. Invalid, non-numeric, null, or incorrectly
56+
formatted ZIP codes are replaced with 0.
57+
tests:
58+
- not_null
59+
60+
- name: country
61+
description: |
62+
Standardized country name. Multiple representations of the United
63+
States (USA, US, U.S.A., United States) are normalized to
64+
'United States'. All other values are categorized as 'Unknown'.
65+
tests:
66+
- not_null
67+
- accepted_values:
68+
arguments:
69+
values: ['United States', 'Unknown']
70+
71+
- name: region
72+
description: |
73+
Customer geographic region. Missing or blank values are replaced
74+
with 'Unknown'.
75+
tests:
76+
- not_null
77+
- accepted_values:
78+
arguments:
79+
values: ['Midwest', 'Northeast', 'South', 'West']

0 commit comments

Comments
 (0)