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 submission #29

Draft
wants to merge 2 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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.tabSize": 2,
"editor.detectIndentation": false
}
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dbt-core = "==1.3.0"
dbt-databricks = {extras = ["odbc"]}
pytest-mock = "*"
glob2 = "*"
numpy = "==1.24.1"

[dev-packages]
pytest = "*"
Expand Down
1,100 changes: 657 additions & 443 deletions Pipfile.lock

Large diffs are not rendered by default.

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

################################################################################
# EXPOSURES https://docs.getdbt.com/reference/exposure-properties
################################################################################
exposures:
- name: fnl_finance_returned_orders
description: Inksacio Dashboard
type: dashboard
url: url: https://inksacio.uk.octopus.engineering/my_certification_finance_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_finance_returned_orders')
17 changes: 17 additions & 0 deletions jaffle_shop/models/final/finance/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

models:
- name: fnl_finance_returned_orders
config:
tags: ['access:public']
meta:
owner: '[email protected]'
description: |
Report on the value of returned orders. 1 row per customer with total returned value for
that customer
columns:
- name: customer_id
description: Primary key
tests:
- unique
- not_null
14 changes: 14 additions & 0 deletions jaffle_shop/models/final/finance/fnl_finance_returned_orders.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
WITH returned_orders AS (
SELECT
customer_id
, amount AS value
FROM {{ ref('wh_orders') }}
WHERE status = 'returned'
GROUP BY customer_id
)

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

################################################################################
# EXPOSURES https://docs.getdbt.com/reference/exposure-properties
################################################################################
exposures:
- name: fnl_sales_first_orders
description: Inksacio Dashboard
type: dashboard
url: url: https://inksacio.uk.octopus.engineering/my_certification_sales_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_sales_first_orders')
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_first_orders
config:
tags: ['access:public']
meta:
owner: '[email protected]'
description: |
Report on the numbers of customers making their first order per month.
columns:
- name: first_order_month
description: Primary key
tests:
- unique
- not_null
14 changes: 14 additions & 0 deletions jaffle_shop/models/final/sales/fnl_sales_first_orders.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
WITH customer_first_orders AS (
SELECT
customer_id
-- Get just the month from the first order date
, DATE_FORMAT(first_order, 'MMMM') As first_order_month
FROM {{ ref('wh_customers') }}
)

SELECT
first_order_month
, COUNT(*) AS number_of_customers
FROM customer_first_orders
GROUP BY first_order_month

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

This file was deleted.

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

models:
- name: stg_customers_pii
config:
tags: ['access:private']
meta:
owner: '[email protected]'
description: |
Staging table for csv containing customer information.
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name
meta:
sensitive: true
- name: last_name
meta:
sensitive: true
- name: stg_customers
config:
tags: ['access:private']
meta:
owner: '[email protected]'
description: |
Staging table for csv containing customer information with PII columns hashed.
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name_hash
tests:
- dbt_expectations.expect_column_to_exist
- name: last_name_hash
tests:
- dbt_expectations.expect_column_to_exist

- name: stg_orders
columns:
- name: order_id
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']

- name: stg_payments
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_seeds/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.
30 changes: 30 additions & 0 deletions jaffle_shop/seeds/_seeds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2

seeds:
- name: raw_customers
description: |
Table containing customer_id, and their first and last name.
config:
column_types:
id: int
first_name: string
last_name: string
- name: raw_orders
description: |
Table containing information about customers orders
config:
column_types:
id: int
user_id: int
order_date: date
status: string
- name: raw_payments
description: |
Table containing information about customers payments
config:
column_types:
id: int
order_id: int
payment_method: string
amount: int

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.