Skip to content

Commit 436ce79

Browse files
committed
Improved the tutorial and fixed data generation!
1 parent 3fa69ab commit 436ce79

File tree

12 files changed

+21124
-20999
lines changed

12 files changed

+21124
-20999
lines changed

elementary_tutorial/cheat_sheets/tutorial_final_schema_with_tests.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ models:
3131

3232
- name: number_of_orders
3333
description: Count of the number of orders a customer has placed
34+
tests:
35+
- elementary.column_anomalies:
36+
config:
37+
severity: warn
38+
tags: ["column_anomalies"]
39+
column_anomalies:
40+
- zero_count
41+
timestamp_column: "signup_date"
3442

3543
- name: customer_lifetime_value
3644
description: Total value (AUD) of a customer's orders
@@ -67,14 +75,6 @@ models:
6775

6876
- name: amount
6977
description: Total amount (AUD) of the order
70-
tests:
71-
- elementary.column_anomalies:
72-
config:
73-
severity: warn
74-
tags: ["column_anomalies"]
75-
column_anomalies:
76-
- zero_count
77-
- zero_percent
7878

7979
- name: credit_card_amount
8080
description: Amount of the order (AUD) paid for by credit card
@@ -98,7 +98,8 @@ models:
9898
tags: ["table_anomalies"]
9999
table_anomalies:
100100
- row_count
101-
freshness_column: order_date
101+
timestamp_column: "order_date"
102+
102103
columns:
103104
- name: order_id
104105
description: This is a unique identifier for an order

elementary_tutorial/dbt_project/models/customers.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ final as (
5858
customers.last_name,
5959
customer_orders.first_order,
6060
customer_orders.most_recent_order,
61-
customer_orders.number_of_orders,
61+
case
62+
when customer_orders.number_of_orders is null then 0
63+
else customer_orders.number_of_orders
64+
end as number_of_orders,
6265
customer_payments.total_amount as customer_lifetime_value,
6366
signups.customer_email,
6467
{% if elementary.get_config_var('anomalies') %}

elementary_tutorial/dbt_project/models/schema.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ models:
55
description: This table has basic information about a customer, as well as some derived facts based on a customer's orders
66
config:
77
tags: ["PII"]
8+
elementary:
9+
timestamp_column: "signup_date"
10+
tests:
11+
- elementary.table_anomalies:
12+
table_anomalies:
13+
- row_count
14+
- elementary.schema_changes
815

916
columns:
1017
- name: customer_id
@@ -24,6 +31,14 @@ models:
2431

2532
- name: number_of_orders
2633
description: Count of the number of orders a customer has placed
34+
tests:
35+
- elementary.column_anomalies:
36+
config:
37+
severity: warn
38+
tags: ["column_anomalies"]
39+
column_anomalies:
40+
- zero_count
41+
timestamp_column: "signup_date"
2742

2843
- name: customer_lifetime_value
2944
description: Total value (AUD) of a customer's orders
@@ -38,7 +53,13 @@ models:
3853
description: This table has basic information about orders, as well as some derived facts based on payments
3954
config:
4055
tags: ["finance"]
56+
elementary:
57+
timestamp_column: "order_date"
4158

59+
tests:
60+
- elementary.dimension_anomalies:
61+
dimensions:
62+
- status
4263
columns:
4364
- name: order_id
4465
description: This is a unique identifier for an order
@@ -72,6 +93,13 @@ models:
7293
config:
7394
tags: ["finance"]
7495

96+
tests:
97+
- elementary.table_anomalies:
98+
tags: ["table_anomalies"]
99+
table_anomalies:
100+
- row_count
101+
timestamp_column: "order_date"
102+
75103
columns:
76104
- name: order_id
77105
description: This is a unique identifier for an order

0 commit comments

Comments
 (0)