Skip to content
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
12 changes: 6 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 0 additions & 69 deletions jaffle_shop/models/customers.sql

This file was deleted.

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

exposures:
- name: fnl_finance
description: Used in Inksacio app
type: application
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: saif.widyatmoko@octoenergy.com
depends_on:
- ref('wh_customers')

models:
- name: fnl_finance
description: This table contains the total value of orders per customer
columns:
- name: customer_id
description: This is a unique identifier for a customer
tests:
- unique
- not_null
- name: customer_lifetime_value
description: This is the total value of orders for a customer
4 changes: 4 additions & 0 deletions jaffle_shop/models/final/final/finance/fnl_finance.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT
customers.customer_id
, customers.customer_lifetime_value
FROM {{ ref('wh_customers') }} AS customers
23 changes: 23 additions & 0 deletions jaffle_shop/models/final/final/sales/_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2

exposures:
- name: fnl_sales
description: Used in Inksacio app
type: application
url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/
owner:
email: saif.widyatmoko@octoenergy.com
depends_on:
- ref('wh_customers')

models:
- name: fnl_sales
description: This table contains the number of new customers per month
columns:
- name: month_start_date
description: This is a date representing the start of a month
tests:
- unique
- not_null
- name: new_customer_count
description: This is the number of new customers in a given month
5 changes: 5 additions & 0 deletions jaffle_shop/models/final/final/sales/fnl_sales.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT
DATE_TRUNC('MONTH', customers.first_order) AS month_start_date
, COUNT(customers.customer_id) AS new_customer_count
FROM {{ ref('wh_customers') }} AS customers
GROUP BY DATE_TRUNC('MONTH', customers.first_order)
56 changes: 0 additions & 56 deletions jaffle_shop/models/orders.sql

This file was deleted.

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

models:
- name: stg_customers
meta:
owner: 'saif.widyatmoko@octoenergy.com'
description: |
This model contains customer data with hashed PII fields for privacy protection.
It is used to ensure that sensitive information is not exposed in the data warehouse.
columns:
- name: customer_id
description: Primary key of the table
tests:
- unique
- not_null
- name: first_name_hashed
description: Hash of the first name for PII protection
- name: last_name_hashed
description: Hash of the last name for PII protection
- name: stg_customers_pii
meta:
owner: 'saif.widyatmoko@octoenergy.com
description: |
This model contains customer data with sensitive fields that are not hashed.
It is used for internal processes where PII is required, but access is restricted.
columns:
- name: customer_id
description: Primary key of the table
tests:
- unique
- not_null
- name: first_name
description: First name of the customer
meta:
sensitive: true
- name: last_name
description: Last name of the customer
meta:
sensitive: true
- name: stg_payments
meta:
owner: 'saif.widyatmoko@octoenergy.com'
description: |
This model contains payment data with methods and amounts.
columns:
- name: payment_id
tests:
- unique
- not_null
- name: payment_method
tests:
- accepted_values:
values: ['credit_card', 'coupon', 'bank_transfer', 'gift_card']
- name: stg_orders
meta:
owner: 'saif.widyatmoko@octoenergy.com'
description: |
This model contains order data with customer and payment information.
columns:
- name: order_id
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']
31 changes: 0 additions & 31 deletions jaffle_shop/models/staging/schema.yml

This file was deleted.

25 changes: 3 additions & 22 deletions jaffle_shop/models/staging/stg_customers.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
with source as (

{#-
Normally we would select from the table here, but we are using seeds to load
our data in this project
#}
select * from {{ ref('raw_customers') }}

),

renamed as (

select
id as customer_id,
first_name,
last_name

from source

)

select * from renamed
SELECT
{{ hash_sensitive_columns('stg_customers_pii')}}
FROM {{ ref('stg_customers_pii')}}
12 changes: 12 additions & 0 deletions jaffle_shop/models/staging/stg_customers_pii.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
WITH source AS (

SELECT * FROM {{ ref('raw_customers') }}

)

SELECT
id AS customer_id
, first_name
, last_name

FROM source
28 changes: 9 additions & 19 deletions jaffle_shop/models/staging/stg_orders.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
with source as (
WITH source AS (

{#-
Normally we would select from the table here, but we are using seeds to load
our data in this project
#}
select * from {{ ref('raw_orders') }}

),

renamed as (

select
id as order_id,
user_id as customer_id,
order_date,
status

from source
SELECT * FROM {{ ref('raw_orders') }}

)

select * from renamed
SELECT
id AS order_id
, user_id AS customer_id
, order_date
, status

FROM source
Loading