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

Dbt cert josh #26

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
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest_plugins = ["dbt.tests.fixtures.project"]
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: fnl_returned_order_value
label: Inkacio
description: fnl_returned_order_value
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('wh_orders')


models:
- name: fnl_returned_order_value
meta:
owner: [email protected]
description: |
One row per customer for total value of returns
columns:
- name: customer_id
description: Primary key
tests:
- unique
- not_null

13 changes: 13 additions & 0 deletions jaffle_shop/models/final/finance/fnl_returned_order_value.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
WITH returned_orders AS (
SELECT
customer_id AS customer_id
,amount as total_amount
FROM {{ ref('wh_orders') }}
evb123 marked this conversation as resolved.
Show resolved Hide resolved
WHERE status = 'returned'
)

SELECT
customer_id
,SUM(COALESCE(total_amount, 0)) AS total_value
FROM returned_orders
GROUP BY customer_id
26 changes: 26 additions & 0 deletions jaffle_shop/models/final/sales/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2


exposures:
- name: fnl_monthly_customer_count
label: Inkacio
description: fnl_monthly_customer_count
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('wh_customers')

models:
- name: fnl_monthly_customer_count
meta:
owner: [email protected]
description: |
One row per customer count for each month based on their first orders.
columns:
- name: first_order_month
description: Primary key
tests:
- unique
- not_null
12 changes: 12 additions & 0 deletions jaffle_shop/models/final/sales/fnl_monthly_customer_count.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
WITH customer_orders AS (
SELECT
customer_id
, DATE_FORMAT(first_order, 'MMMM') As order_month
FROM {{ ref('wh_customers') }}
)

SELECT
first_order AS first_order_month
, COUNT(*) AS customer_count
FROM customer_orders
GROUP BY first_order
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
version: 2

models:

- name: stg_customers
meta:
owner: "[email protected]"
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name
tests:
- dbt_expectations.expect_column_to_exist
- name: last_name
tests:
- dbt_expectations.expect_column_to_exist

- name: stg_customers_pii
meta:
owner: "[email protected]"
sensitive: true
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name
meta:
sensitive: true
- name: last_name
meta:
sensitive: true

- name: stg_orders
meta:
owner: "[email protected]"
columns:
- name: order_id
tests:
Expand All @@ -20,6 +47,8 @@ models:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']

- name: stg_payments
meta:
owner: "[email protected]"
columns:
- name: payment_id
tests:
Expand Down
4 changes: 4 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,4 @@

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,8 +1,10 @@
version: 2

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

columns:
evb123 marked this conversation as resolved.
Show resolved Hide resolved
- name: customer_id
Expand All @@ -29,9 +31,10 @@ models:
- name: total_order_amount
description: Total value (AUD) of a customer's orders

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

meta:
owner: "[email protected]"
columns:
- name: order_id
tests:
Expand Down
6 changes: 6 additions & 0 deletions jaffle_shop/seeds/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2

seed:
- name: raw_customers
- name: raw_orders
- name: raw_payments
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.