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

George dbt gatekeeper test #12

Open
wants to merge 5 commits into
base: elliot-cert
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
12 changes: 0 additions & 12 deletions jaffle_shop/models/final/finance/_exposures.yml

This file was deleted.

17 changes: 16 additions & 1 deletion jaffle_shop/models/final/finance/_models.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
version: 2

exposures:
- name: customer_return_total
description:
Inksacio App to show the total sum of customer returns
, per customer (for both completed and upcoming)
type: dashboard
url: https://inksacio.eks.octojaffle.engineering/customer_return_totals/
owner:
name: 'Elliot Taylor'
email: [email protected]
depends_on:
- ref('fnl_finance_customerreturnstotal')
models:
- name: fnl_finance_customerreturnstotal
meta:
owner: [email protected]
team_owner: '!subteam^S7K9CR63D' #@datateam
description: >
This table gives one row per customer, with the total of their completed returns,
pending_returns and the sum of the 2
Expand All @@ -10,4 +25,4 @@ models:
description: primary key
tests:
- unique
- not_null
- not_null
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% set return_states = ['returned', 'return_pending'] %}

select
SELECT
orders.customer_id

{% for return_state in return_states -%}
Expand All @@ -9,6 +9,6 @@ select

, SUM(orders.amount_dollars) AS sum_return_amount_dollars

from {{ ref('wh_orders') }} AS orders
where orders.status IN ('returned', 'return_pending')
FROM {{ ref('wh_orders') }} AS orders
WHERE orders.status IN ('returned', 'return_pending')
GROUP BY orders.customer_id
12 changes: 0 additions & 12 deletions jaffle_shop/models/final/sales/_exposures.yml

This file was deleted.

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

exposures:
- name: new_customer_history
description: Inksacio App to show monthly new customer history
type: dashboard
url: https://inksacio.eks.octojaffle.engineering/new_customer_history/
owner:
name: 'Elliot Taylor'
email: [email protected]
depends_on:
- ref('fnl_sales_newcustomerhistory')
models:
- name: fnl_sales_newcustomerhistory
meta:
owner: [email protected]
team_owner: '!subteam^S7K9CR63D' #@datateam
description: >
This table gives one row per truncated month with the count
of customers that have created their first order within this month
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select
date_trunc('month', first_order) AS first_order_month
, count(*) AS number_customers
from {{ ref('wh_customers') }}
SELECT
DATE_TRUNC('month', first_order) AS first_order_month
, COUNT(DISTINCT customer_id) AS number_customers
FROM {{ ref('wh_customers') }}
25 changes: 22 additions & 3 deletions jaffle_shop/models/staging/src_seed/_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ models:
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']

- name: stg_payments
description: staging layer for all payments with a FK to order
columns:
Expand All @@ -26,12 +25,32 @@ models:
tests:
- accepted_values:
values: ['credit_card', 'coupon', 'bank_transfer', 'gift_card']

- name: stg_customers_pii
description: >
staging layer for customers, PII hashed
columns:
- name: customer_id
description: Primary Key
tests:
- unique
- not_null
- name: first_name
meta:
sensitive: true
- name: last_name
meta:
sensitive: true
- name: stg_customers
description: staging layer for all customers, PII hashed
columns:
- name: customer_id
description: Primary Key
tests:
- unique
- not_null
- not_null
- name: first_name_hash
tests:
- dbt_expectations.expect_column_to_exist
- name: last_name_hash
tests:
- dbt_expectations.expect_column_to_exist
18 changes: 0 additions & 18 deletions jaffle_shop/models/staging/src_seed/sensitive/_models.yml

This file was deleted.

This file was deleted.

23 changes: 23 additions & 0 deletions jaffle_shop/models/staging/src_seed/stg_customers_pii.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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
23 changes: 12 additions & 11 deletions jaffle_shop/models/staging/src_seed/stg_orders.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
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') }}
SELECT *
FROM {{ ref('raw_orders') }}

),

renamed as (
renamed AS (

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

from source
SELECT
id AS order_id
, user_id AS customer_id
, order_date
, status
FROM source

)

select * from renamed
SELECT *
FROM renamed
25 changes: 12 additions & 13 deletions jaffle_shop/models/staging/src_seed/stg_payments.sql
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
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_payments') }}
SELECT * FROM {{ ref('raw_payments') }}

),

renamed as (
renamed AS (

select
id as payment_id,
order_id,
payment_method,

-- `amount` is currently stored in cents, so we convert it to dollars
amount / 100 as amount_dollars

from source
SELECT
id AS payment_id
, order_id
, payment_method
-- `amount` is currently stored in cents, so we convert it to dollars
, amount / 100 AS amount_dollars
FROM source

)

select * from renamed
SELECT *
FROM renamed
38 changes: 38 additions & 0 deletions jaffle_shop/seeds/_seeds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 2

seeds:
- name: dbt_project_evaluator_exceptions
description: >
Table exceptions to avoid staging to staging failures
config:
column_types:
fct_name: string
column_name: string
id_to_exclude: string
comment: string
- name: raw_customers
description: >
Customer names and IDs
config:
column_types:
id: bigint
first_name: string
last_name: string
- name: raw_orders
description: >
Customer orders by id, date, and status
config:
column_types:
id: bigint
user_id: bigint
order_date: date
status: string
- name: raw_payments
description: >
Customer payments by id, payment method, and amount paid
config:
column_types:
id: bigint
order_id: bigint
payment_method: string
amount: bigint