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

V2 gatekeeper cert kensuke #22

Open
wants to merge 5 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
1,106 changes: 679 additions & 427 deletions Pipfile.lock

Large diffs are not rendered by default.

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

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

18 changes: 18 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,18 @@
WITH returned_orders AS (
SELECT *
FROM {{ ref('wh_orders') }}
WHERE status = 'returned'
)

customers AS (
SELECT *
FROM {{ref('stg_customers') }}
)

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

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
Expand Up @@ -7,6 +7,10 @@ models:
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
columns:
Expand Down
20 changes: 20 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,20 @@
version: 2

models:
name: stg_customers_pii
meta:
owner: [email protected]
sensitive: True
description: One row per customer information.
columns:
- name: customer_id
description: Primary key
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') }}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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
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.

Expand All @@ -29,9 +29,9 @@ 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
description: |
This table has basic information about orders, as well as some derived facts based on payments
columns:
- name: order_id
tests:
Expand Down
File renamed without changes.
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 All @@ -20,7 +20,6 @@ customer_orders as (

select
customer_id,

min(order_date) as first_order,
max(order_date) as most_recent_order,
count(order_id) as 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.