Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 57c7e97

Browse files
Add finance and sales models for final layer
1 parent 1d0c996 commit 57c7e97

5 files changed

Lines changed: 55 additions & 0 deletions

File tree

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest_plugins = ["dbt.tests.fixtures.project"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
3+
models:
4+
- name: fnl_returned_order_value
5+
meta:
6+
owner: joshua.oconnor@kraken.tech
7+
description: |
8+
One row per customer for total value of returns
9+
columns:
10+
- name: customer_id
11+
description: Primary key
12+
tests:
13+
- unique
14+
- not_null
15+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
WITH returned_orders AS (
2+
SELECT
3+
orders.customer_id AS customer_id,
4+
orders.amount as total_amount
5+
FROM {{ ref('wh_orders') }}
6+
WHERE orders.status = 'returned'
7+
)
8+
9+
SELECT
10+
customer_id,
11+
SUM(COALESCE(total_amount, 0)) AS total_value
12+
FROM returned_orders
13+
GROUP BY customer_id
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
3+
models:
4+
- name: fnl_monthly_customer_count
5+
meta:
6+
owner: joshua.oconnor@kraken.tech
7+
description: |
8+
One row per customer count for each month based on their first orders.
9+
columns:
10+
- name: first_order_month
11+
description: Primary key
12+
tests:
13+
- unique
14+
- not_null
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
WITH customer_orders AS (
2+
SELECT
3+
customer_id
4+
, DATE_FORMAT(first_order, 'MMMM') As order_month
5+
FROM {{ ref('wh_customers') }}
6+
)
7+
8+
SELECT
9+
first_order AS first_order_month
10+
, COUNT(*) AS customer_count
11+
FROM customer_orders
12+
GROUP BY first_order

0 commit comments

Comments
 (0)