Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
Open
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
202 changes: 101 additions & 101 deletions data/raw_customers.csv
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
id,first_name,last_name
1,Michael,P.
2,Shawn,M.
3,Kathleen,P.
4,Jimmy,C.
5,Katherine,R.
6,Sarah,R.
7,Martin,M.
8,Frank,R.
9,Jennifer,F.
10,Henry,W.
11,Fred,S.
12,Amy,D.
13,Kathleen,M.
14,Steve,F.
15,Teresa,H.
16,Amanda,H.
17,Kimberly,R.
18,Johnny,K.
19,Virginia,F.
20,Anna,A.
21,Willie,H.
22,Sean,H.
23,Mildred,A.
24,David,G.
25,Victor,H.
26,Aaron,R.
27,Benjamin,B.
28,Lisa,W.
29,Benjamin,K.
30,Christina,W.
31,Jane,G.
32,Thomas,O.
33,Katherine,M.
34,Jennifer,S.
35,Sara,T.
36,Harold,O.
37,Shirley,J.
38,Dennis,J.
39,Louise,W.
40,Maria,A.
41,Gloria,C.
42,Diana,S.
43,Kelly,N.
44,Jane,R.
45,Scott,B.
46,Norma,C.
47,Marie,P.
48,Lillian,C.
49,Judy,N.
50,Billy,L.
51,Howard,R.
52,Laura,F.
53,Anne,B.
54,Rose,M.
55,Nicholas,R.
56,Joshua,K.
57,Paul,W.
58,Kathryn,K.
59,Adam,A.
60,Norma,W.
61,Timothy,R.
62,Elizabeth,P.
63,Edward,G.
64,David,C.
65,Brenda,W.
66,Adam,W.
67,Michael,H.
68,Jesse,E.
69,Janet,P.
70,Helen,F.
71,Gerald,C.
72,Kathryn,O.
73,Alan,B.
74,Harry,A.
75,Andrea,H.
76,Barbara,W.
77,Anne,W.
78,Harry,H.
79,Jack,R.
80,Phillip,H.
81,Shirley,H.
82,Arthur,D.
83,Virginia,R.
84,Christina,R.
85,Theresa,M.
86,Jason,C.
87,Phillip,B.
88,Adam,T.
89,Margaret,J.
90,Paul,P.
91,Todd,W.
92,Willie,O.
93,Frances,R.
94,Gregory,H.
95,Lisa,P.
96,Jacqueline,A.
97,Shirley,D.
98,Nicole,M.
99,Mary,G.
100,Jean,M.
id,first_name,last_name,created
1,Michael,P.,2017-01-30 06:00:00
2,Shawn,M.,2017-01-30 10:00:00
3,Kathleen,P.,2017-01-30 01:00:00
4,Jimmy,C.,2017-03-30 02:00:00
5,Katherine,R.,2017-02-10 03:00:00
6,Sarah,R.,2017-01-30 11:00:00
7,Martin,M.,2017-01-30 11:00:00
8,Frank,R.,2017-01-30 11:00:00
9,Jennifer,F.,2017-01-30 11:00:00
10,Henry,W.,2017-01-30 11:00:00
11,Fred,S.,2017-01-30 11:00:00
12,Amy,D.,2017-01-30 11:00:00
13,Kathleen,M.,2017-01-30 11:00:00
14,Steve,F.,2017-01-30 11:00:00
15,Teresa,H.,2017-01-30 11:00:00
16,Amanda,H.,2017-01-30 11:00:00
17,Kimberly,R.,2017-01-30 11:00:00
18,Johnny,K.,2017-01-30 11:00:00
19,Virginia,F.,2017-01-30 11:00:00
20,Anna,A.,2017-01-30 11:00:00
21,Willie,H.,2017-01-30 11:00:00
22,Sean,H.,2017-01-30 11:00:00
23,Mildred,A.,2017-01-30 11:00:00
24,David,G.,2017-01-30 11:00:00
25,Victor,H.,2017-01-30 11:00:00
26,Aaron,R.,2017-01-30 11:00:00
27,Benjamin,B.,2017-01-30 11:00:00
28,Lisa,W.,2017-01-30 11:00:00
29,Benjamin,K.,2017-01-30 11:00:00
30,Christina,W.,2017-01-30 11:00:00
31,Jane,G.,2017-01-30 11:00:00
32,Thomas,O.,2017-01-30 11:00:00
33,Katherine,M.,2017-01-30 11:00:00
34,Jennifer,S.,2017-01-30 11:00:00
35,Sara,T.,2017-01-30 11:00:00
36,Harold,O.,2017-01-30 11:00:00
37,Shirley,J.,2017-01-30 11:00:00
38,Dennis,J.,2017-01-30 11:00:00
39,Louise,W.,2017-01-30 11:00:00
40,Maria,A.,2017-01-30 11:00:00
41,Gloria,C.,2017-01-30 11:00:00
42,Diana,S.,2017-01-30 11:00:00
43,Kelly,N.,2017-01-30 11:00:00
44,Jane,R.,2017-01-30 11:00:00
45,Scott,B.,2017-01-30 11:00:00
46,Norma,C.,2017-01-30 11:00:00
47,Marie,P.,2017-01-30 11:00:00
48,Lillian,C.,2017-01-30 11:00:00
49,Judy,N.,2017-01-30 11:00:00
50,Billy,L.,2017-01-30 11:00:00
51,Howard,R.,2017-01-30 11:00:00
52,Laura,F.,2017-01-30 11:00:00
53,Anne,B.,2017-01-30 11:00:00
54,Rose,M.,2017-01-30 11:00:00
55,Nicholas,R.,2017-01-30 11:00:00
56,Joshua,K.,2017-01-30 11:00:00
57,Paul,W.,2017-01-30 11:00:00
58,Kathryn,K.,2017-01-30 11:00:00
59,Adam,A.,2017-01-30 11:00:00
60,Norma,W.,2017-01-30 11:00:00
61,Timothy,R.,2017-01-30 11:00:00
62,Elizabeth,P.,2017-01-30 11:00:00
63,Edward,G.,2017-01-30 11:00:00
64,David,C.,2017-01-30 11:00:00
65,Brenda,W.,2017-01-30 11:00:00
66,Adam,W.,2017-02-11 03:00:00
67,Michael,H.,2017-01-30 11:00:00
68,Jesse,E.,2017-01-30 10:00:00
69,Janet,P.,2017-01-30 11:00:00
70,Helen,F.,2017-02-10 03:00:00
71,Gerald,C.,2017-01-30 11:00:00
72,Kathryn,O.,2017-01-28 11:00:00
73,Alan,B.,2017-01-30 11:00:00
74,Harry,A.,2017-01-30 10:00:00
75,Andrea,H.,2017-01-24 11:00:00
76,Barbara,W.,2017-01-30 11:00:00
77,Anne,W.,2017-01-30 11:00:00
78,Harry,H.,2017-01-30 11:00:00
79,Jack,R.,2017-01-30 06:00:00
80,Phillip,H.,2017-01-15 11:00:00
81,Shirley,H.,2017-02-10 03:00:00
82,Arthur,D.,2017-01-30 11:00:00
83,Virginia,R.,2017-01-30 11:00:00
84,Christina,R.,2017-01-30 11:00:00
85,Theresa,M.,2017-01-30 11:00:00
86,Jason,C.,2017-01-30 11:00:00
87,Phillip,B.,2017-01-30 01:00:00
88,Adam,T.,2017-01-30 11:00:00
89,Margaret,J.,2017-01-30 11:00:00
90,Paul,P.,2017-01-30 11:00:00
91,Todd,W.,2017-02-10 03:00:00
92,Willie,O.,2017-01-30 11:00:00
93,Frances,R.,2017-01-18 11:00:00
94,Gregory,H.,2017-01-30 03:00:00
95,Lisa,P.,2017-01-30 11:00:00
96,Jacqueline,A.,2017-01-30 11:00:00
97,Shirley,D.,2017-01-30 11:00:00
98,Nicole,M.,2017-01-30 11:00:00
99,Mary,G.,2017-01-19 11:00:00
100,Jean,M.,2017-01-30 07:00:00
6 changes: 6 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ models:
materialized: table
staging:
materialized: view

seeds:
jaffle_shop:
raw_customers:
+column_types:
created: timestamp
1 change: 1 addition & 0 deletions models/customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final as (
customers.customer_id,
customers.first_name,
customers.last_name,
customers.created,
customer_orders.first_order,
customer_orders.most_recent_order,
customer_orders.number_of_orders,
Expand Down
1 change: 1 addition & 0 deletions models/payments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select * from {{ ref('stg_payments') }}
70 changes: 59 additions & 11 deletions models/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,39 @@ models:
tests:
- unique
- not_null
meta:
metrics:
unique_customer_count:
type: count_distinct

- name: first_name
description: Customer's first name. PII.

- name: last_name
description: Customer's last name. PII.

- name: first_order
description: Date (UTC) of a customer's first order

- name: most_recent_order
description: Date (UTC) of a customer's most recent order

- name: number_of_orders
description: Count of the number of orders a customer has placed

- name: total_order_amount
description: Total value (AUD) of a customer's orders
- name: created
description: Timestamp (UTC) when customer was created

- name: orders
description: This table has basic information about orders, as well as some derived facts based on payments

meta:
joins:
- join: customers
sql_on: ${customers.customer_id} = ${orders.customer_id}


columns:
- name: order_id
tests:
- unique
- not_null
description: This is a unique identifier for an order
meta:
metrics:
unique_order_count:
type: count_distinct

- name: customer_id
description: Foreign key to the customers table
Expand All @@ -49,6 +54,12 @@ models:

- name: order_date
description: Date (UTC) that the order was placed
meta:
metrics:
date_of_first_order:
type: min
date_of_most_recent_order:
type: max

- name: status
description: '{{ doc("orders_status") }}'
Expand All @@ -60,6 +71,10 @@ models:
description: Total amount (AUD) of the order
tests:
- not_null
meta:
metrics:
avg_amount:
type: average

- name: credit_card_amount
description: Amount of the order (AUD) paid for by credit card
Expand All @@ -80,3 +95,36 @@ models:
description: Amount of the order (AUD) paid for by gift card
tests:
- not_null

- name: payments
description: This table has information about individual payments

meta:
joins:
- join: orders
sql_on: ${orders.order_id} = ${payments.order_id}
- join: customers
sql_on: ${customers.customer_id} = ${orders.customer_id}

columns:
- name: payment_id
description: This is a unique identifier for a payment
meta:
metrics:
unique_payment_count:
type: count_distinct
description: count of all payments

- name: order_id
description: Foreign key to the orders table

- name: payment_method
description: Method of payment used, for example credit card

- name: amount
description: Total amount (AUD) of the individual payment
meta:
metrics:
total_revenue:
type: sum
description: Sum of all payments
3 changes: 2 additions & 1 deletion models/staging/stg_customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ renamed as (
select
id as customer_id,
first_name,
last_name
last_name,
created

from source

Expand Down