diff --git a/conftest.py b/conftest.py new file mode 100644 index 000000000..b5b7f3629 --- /dev/null +++ b/conftest.py @@ -0,0 +1 @@ +pytest_plugins = ["dbt.tests.fixtures.project"] \ No newline at end of file diff --git a/jaffle_shop/models/final/finance/_models.yml b/jaffle_shop/models/final/finance/_models.yml new file mode 100644 index 000000000..d96149cd7 --- /dev/null +++ b/jaffle_shop/models/final/finance/_models.yml @@ -0,0 +1,28 @@ +version: 2 + + +exposures: + - name: fnl_returned_order_value + label: Inkacio + description: fnl_returned_order_value + type: dashboard + url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/ + owner: + email: joshua.oconnor@kraken.tech + depends_on: + - ref('wh_orders') + + +models: +- name: fnl_returned_order_value + meta: + owner: joshua.oconnor@kraken.tech + description: | + One row per customer for total value of returns + columns: + - name: customer_id + description: Primary key + tests: + - unique + - not_null + \ No newline at end of file diff --git a/jaffle_shop/models/final/finance/fnl_returned_order_value.sql b/jaffle_shop/models/final/finance/fnl_returned_order_value.sql new file mode 100644 index 000000000..52f71e22f --- /dev/null +++ b/jaffle_shop/models/final/finance/fnl_returned_order_value.sql @@ -0,0 +1,13 @@ +WITH returned_orders AS ( + SELECT + customer_id AS customer_id + ,amount as total_amount + FROM {{ ref('wh_orders') }} + WHERE status = 'returned' +) + +SELECT + customer_id + ,SUM(COALESCE(total_amount, 0)) AS total_value +FROM returned_orders +GROUP BY customer_id \ No newline at end of file diff --git a/jaffle_shop/models/final/sales/_models.yml b/jaffle_shop/models/final/sales/_models.yml new file mode 100644 index 000000000..58ad7105a --- /dev/null +++ b/jaffle_shop/models/final/sales/_models.yml @@ -0,0 +1,26 @@ +version: 2 + + +exposures: + - name: fnl_monthly_customer_count + label: Inkacio + description: fnl_monthly_customer_count + type: dashboard + url: https://inksacio.eks.octopus.engineering/my_certification_dashboard/ + owner: + email: joshua.oconnor@kraken.tech + depends_on: + - ref('wh_customers') + +models: +- name: fnl_monthly_customer_count + meta: + owner: joshua.oconnor@kraken.tech + 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 \ No newline at end of file diff --git a/jaffle_shop/models/final/sales/fnl_monthly_customer_count.sql b/jaffle_shop/models/final/sales/fnl_monthly_customer_count.sql new file mode 100644 index 000000000..8ba784926 --- /dev/null +++ b/jaffle_shop/models/final/sales/fnl_monthly_customer_count.sql @@ -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 \ No newline at end of file