Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit dbt-gatekeeper-certification #7

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions jaffle_shop/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

sources:
- name: src_seed
schema: jaffle_shop
tables:
- name: raw_customers
- name: raw_orders
- name: raw_payments
28 changes: 28 additions & 0 deletions jaffle_shop/models/final/finance/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2

exposures:
- name: customer_lifetime_returns_value_dashboard
label: Customer lifetime returns value dashboard
description: A dashboard for the lifetime value (total amount) of returns from each customer.
type: dashboard
url: https://prod-apnortheast-a.online.tableau.com/#/site/octopusenergyjapan/home/customerlifetimereturns
owner:
email: "[email protected]"
depends_on:
- ref('fnl_finance_customerlifetimereturns')

models:
- name: fnl_finance_customerlifetimereturns
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: |
Table with the total sales for each customer.
columns:
- name: customer_id
description: Unique customer id.
tests:
- unique
- not_null
- name: customer_lifetime_returns
description: Total value of all orders returned by customer.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
customer_id
, SUM(amount) as customer_lifetime_returns
FROM {{ ref('wh_orders') }}
WHERE status = 'returned'
GROUP BY customer_id
28 changes: 28 additions & 0 deletions jaffle_shop/models/final/sales/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2

exposures:
- name: new_customers_dashboard
label: Montlhly new customers dashboard
description: A dashboard for the number of new customers making first orders each month.
type: dashboard
url: https://prod-apnortheast-a.online.tableau.com/#/site/octopusenergyjapan/home/monthlynewcustomers
owner:
email: "[email protected]"
depends_on:
- ref('fnl_sales_newcustomers')

models:
- name: fnl_sales_newcustomers
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: |
Count of new customers (i.e. ones making their first order) each month.
columns:
- name: year_month
description: Year and month.
tests:
- unique
- not_null
- name: new_customers
description: Number of new customers making first orders that month.
12 changes: 12 additions & 0 deletions jaffle_shop/models/final/sales/fnl_sales_newcustomers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
WITH customer_first_orders AS (
SELECT
DATE_TRUNC('MONTH', first_order) AS year_month
FROM {{ ref('wh_customers') }}
WHERE first_order IS NOT NULL
)

SELECT
year_month
, COUNT(1) AS new_customers
FROM customer_first_orders
GROUP BY year_month
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ version: 2

models:
- name: stg_customers
description: |
A version of `stg_customers_pii` with sensitive details hashed. For more details, see the PII
table.
columns:
- name: customer_id
tests:
- unique
- not_null

- name: stg_orders
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: |
Table of all orders made at our Jaffle Shop!
columns:
- name: order_id
tests:
Expand All @@ -20,6 +28,11 @@ models:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']

- name: stg_payments
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: |
Table of all payments made to our Jaffle Shop!
columns:
- name: payment_id
tests:
Expand Down
23 changes: 23 additions & 0 deletions jaffle_shop/models/staging/src_seed/sensitive/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2

models:
- name: stg_customers_pii
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: |
Table of customers of our Jaffle Shop!

Contains PII.
columns:
- name: customer_id
description: Unique customer identifier.
tests:
- unique
- not_null
- name: first_name
meta:
sensitive: true
- name: last_name
meta:
sensitive: true
3 changes: 3 additions & 0 deletions jaffle_shop/models/staging/src_seed/stg_customers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
{{ hash_sensitive_columns("stg_customers_pii") }}
FROM {{ ref("stg_customers_pii") }}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,81 +1,71 @@
version: 2

models:
- name: customers
- name: wh_customers
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: This table has basic information about a customer, as well as some derived facts based on a customer's orders

columns:
- name: customer_id
description: This is a unique identifier for a customer
tests:
- unique
- not_null

- 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: orders
- name: wh_orders
meta:
owner: "[email protected]"
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers
description: This table has basic information about orders, as well as some derived facts based on payments

columns:
- name: order_id
tests:
- unique
- not_null
description: This is a unique identifier for an order

- name: customer_id
description: Foreign key to the customers table
tests:
- not_null
- relationships:
to: ref('customers')
to: ref('wh_customers')
field: customer_id

- name: order_date
description: Date (UTC) that the order was placed

- name: status
description: '{{ doc("orders_status") }}'
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']

- name: amount
description: Total amount (AUD) of the order
tests:
- not_null

- name: credit_card_amount
description: Amount of the order (AUD) paid for by credit card
tests:
- not_null

- name: coupon_amount
description: Amount of the order (AUD) paid for by coupon
tests:
- not_null

- name: bank_transfer_amount
description: Amount of the order (AUD) paid for by bank transfer
tests:
- not_null

- name: gift_card_amount
description: Amount of the order (AUD) paid for by gift card
tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ final as (

select
customers.customer_id,
customers.first_name,
customers.last_name,
customers.first_name_hash,
customers.last_name_hash,
customer_orders.first_order,
customer_orders.most_recent_order,
customer_orders.number_of_orders,
Expand Down
2 changes: 2 additions & 0 deletions jaffle_shop/seeds/dbt_project_evaluator_exceptions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fct_name,column_name,id_to_exclude,comment
fct_staging_dependent_on_staging,parent,stg_customers_pii,Scrubbing pii permitted in staging layer.