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

Maja dbt certification #23

Draft
wants to merge 8 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 .user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
id: 292d2798-5b54-468e-a539-9b71028dd88f
1,048 changes: 616 additions & 432 deletions Pipfile.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions jaffle_shop/models/.sqlfluffignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# sqlfluff incompatible with models using hash_sensitive_columns macro - disabled till resolved.

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

exposures:
- name: new_customers
label: New customers
description: Inksacio dashboard
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_sales_newcustomers')
- name: returns_value
label: Value of returns per customer
description: Inksacio dashboard
type: dashboard
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: [email protected]
depends_on:
- ref('fnl_finance_returnsvalue')

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_returnsvalue
meta:
owner: "[email protected]"
description: |
Value of returns by customer id
columns:
- name: customer_id
description: This is a unique identifier for a customer
tests:
- unique
- not_null
- name: total_return_value
description: Total value of a customer's returns
10 changes: 10 additions & 0 deletions jaffle_shop/models/final/finance/fnl_finance_returnsvalue.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
WITH fnl_finance_returnsvalue AS (
SELECT
orders.customer_id AS customer_id
, SUM(orders.amount) AS total_return_value
FROM {{ref('wh_orders')}} as orders
WHERE orders.status = 'returned'
GROUP BY orders.customer_id
)

SELECT * FROM fnl_finance_returnsvalue
17 changes: 17 additions & 0 deletions jaffle_shop/models/final/sales/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

models:
- name: fnl_sales_newcustomers
meta:
owner: "[email protected]"
description: |
Number of new customers by month
columns:
- name: first_order_month
description: |
This is a unique identifier for month and year
tests:
- unique
- not_null
- name: new_customers_count
description: Total number of new customers
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 first_orders AS (
SELECT
customers.customer_id
, DATE_FORMAT(customers.first_order, '%y-%m') AS first_order_month
FROM {{ ref('wh_customers') }} AS customers
)

SELECT
first_order_month
, COUNT(*) AS new_customers_count
FROM first_orders
GROUP BY first_order_month
31 changes: 0 additions & 31 deletions jaffle_shop/models/staging/schema.yml

This file was deleted.

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

models:
- name: stg_customers_pii
meta:
owner: "[email protected]"
sensitive: true
description: List of jaffle shop customers
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name
meta:
sensitive: true
- name: last_name
meta:
sensitive: true

- name: stg_customers
meta:
owner: "[email protected]"
description: List of customer ids
columns:
- name: customer_id
tests:
- unique
- not_null
- name: first_name_hash
tests:
- dbt_expectations.expect_columns_to_exist
- name: last_name_hash
tests:
- dbt_expectations.expect_columns_to_exist

- name: stg_orders
meta:
owner: "[email protected]"
description: List of customer orders
columns:
- name: order_id
tests:
- unique
- not_null
- name: customer_id
- name: order_date
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']


- name: stg_payments
meta:
owner: "[email protected]"
description: List of payments
columns:
- name: payment_id
tests:
- unique
- not_null
- name: order_id
- name: payment_method
tests:
- accepted_values:
values: ['credit_card', 'coupon', 'bank_transfer', 'gift_card']
- name: amount

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,9 +1,12 @@
version: 2

models:
- name: customers
description: This table has basic information about a customer, as well as some derived facts based on a customer's orders

- name: wh_customers
meta:
owner: "[email protected]"
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
Expand All @@ -29,9 +32,12 @@ models:
- name: total_order_amount
description: Total value (AUD) of a customer's orders

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

- name: wh_orders
meta:
owner: "[email protected]"
description: |
This table has basic information about orders, as well as some derived facts based on payments

columns:
- name: order_id
tests:
Expand All @@ -44,7 +50,7 @@ models:
tests:
- not_null
- relationships:
to: ref('customers')
to: ref('wh_jaffle_customers')
field: customer_id

- name: order_date
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
with customers as (

select * from {{ ref('stg_customers') }}
select * from {{ ref('stg_customers_pii') }}

),

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.
6 changes: 3 additions & 3 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
packages:
- package: dbt-labs/dbt_utils
version: 0.8.6
version: 1.1.1
- package: dbt-labs/spark_utils
version: 0.3.0
- package: dbt-labs/codegen
version: 0.7.0
version: 0.12.1
- package: dbt-labs/dbt_project_evaluator
version: 0.1.3
version: 0.6.2