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

Luke r-d dbt cert #28

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
69 changes: 0 additions & 69 deletions jaffle_shop/models/customers.sql

This file was deleted.

12 changes: 12 additions & 0 deletions jaffle_shop/models/final/finance/_exposures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

exposures:
- name: fnl_finance_customerreturns
label: fnl_finance_customerreturns
description: Inksacio data app with dashboard showing the financial value of customer returns
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_finance_customerreturns')
16 changes: 16 additions & 0 deletions jaffle_shop/models/final/finance/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

models:
- name: fnl_finance_customerreturns
access: public
config:
group: industry_operations
meta:
owner: [email protected]
description: |
This model contains one row per customer and the total financial value of their returned orders.
columns:
- name: customer_id
tests:
- unique
- not_null
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SELECT
customer_id
, SUM(amount) AS total_amount_returned

FROM {{ ref('wh_orders') }}

WHERE status = 'returned'

GROUP BY customer_id
12 changes: 12 additions & 0 deletions jaffle_shop/models/final/sales/_exposures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

exposures:
- name: fnl_sales_newcustomersmonthly
label: fnl_sales_newcustomersmonthly
description: Inksacio data app with dashboard showing the total number of new customers per month
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_sales_newcustomersmonthly')
16 changes: 16 additions & 0 deletions jaffle_shop/models/final/sales/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

models:
- name: fnl_sales_newcustomersmonthly
access: public
config:
group: industry_operations
meta:
owner: [email protected]
description: |
This model contains one row per month and the total number of customers making their first order in that month.
columns:
- name: first_order_month
tests:
- unique
- not_null
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
DATE_TRUNC('month', first_order) AS first_order_month
-- No need to use count distinct here, as wh_customers has one row per customer
, COUNT(customer_id) AS new_customers

FROM {{ ref('wh_customers') }} AS customers

GROUP BY DATE_TRUNC('month', first_order)
56 changes: 0 additions & 56 deletions jaffle_shop/models/orders.sql

This file was deleted.

31 changes: 0 additions & 31 deletions jaffle_shop/models/staging/schema.yml

This file was deleted.

73 changes: 73 additions & 0 deletions jaffle_shop/models/staging/src_seed/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
version: 2

models:
- name: stg_customers_pii
access: public
config:
group: industry_operations
meta:
owner: [email protected]
sensitive: true
description: |
This model contains one row per customer, alongside their first and last time.
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name
meta:
sensitive: true
- name: last_name
meta:
sensitive: true

- name: stg_customers
access: public
config:
group: industry_operations
owner: [email protected]
description: |
This model contains one row per customer, alongside their first and last time, which
are hashed to protect personally identifiable information (PII).
columns:
- name: customer_id
tests:
- unique
- not_null

- name: stg_orders
access: public
config:
group: industry_operations
owner: [email protected]
description: |
This model contains one row per order made by a customer, alongside
the order date and status.
columns:
- name: order_id
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']

- name: stg_payments
access: public
config:
group: industry_operations
owner: [email protected]
description: |
This model contains one row per payment associated with an order, alongside
the payment method.
columns:
- name: payment_id
tests:
- unique
- not_null
- name: payment_method
tests:
- accepted_values:
values: ['credit_card', 'coupon', 'bank_transfer', 'gift_card']
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') }}
6 changes: 6 additions & 0 deletions jaffle_shop/models/staging/src_seed/stg_customers_pii.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
id AS customer_id
, NULLIF(first_name, '') AS first_name
, NULLIF(last_name, '') AS last_name

FROM {{ ref('raw_customers') }}
7 changes: 7 additions & 0 deletions jaffle_shop/models/staging/src_seed/stg_orders.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT
id AS order_id
, user_id AS customer_id
, order_date
, NULLIF(status, '') AS status

FROM {{ ref('raw_orders') }}
8 changes: 8 additions & 0 deletions jaffle_shop/models/staging/src_seed/stg_payments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
id AS payment_id
, order_id
, NULLIF(payment_method, '') AS payment_method
-- `amount` is currently stored in cents, so we convert it to dollars
, amount / 100 AS amount

FROM {{ ref('raw_payments') }}
22 changes: 0 additions & 22 deletions jaffle_shop/models/staging/stg_customers.sql

This file was deleted.

23 changes: 0 additions & 23 deletions jaffle_shop/models/staging/stg_orders.sql

This file was deleted.

Loading