-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into manifest-single-node-path
- Loading branch information
Showing
26 changed files
with
15,653 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## `jaffle_shop` | ||
|
||
`jaffle_shop` is a fictional ecommerce store. This dbt project transforms raw data from an app database into a customers and orders model ready for analytics. | ||
|
||
See [dbt's documentation](https://github.com/dbt-labs/jaffle_shop) for more info. | ||
|
||
### Modifications | ||
|
||
This project has been modified from the original to highlight some of the features of Cosmos. Namely: | ||
|
||
- tags have been added to the models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: 'jaffle_shop' | ||
|
||
config-version: 2 | ||
version: '0.1' | ||
|
||
profile: 'jaffle_shop' | ||
|
||
model-paths: ["models"] | ||
seed-paths: ["seeds"] | ||
test-paths: ["tests"] | ||
analysis-paths: ["analysis"] | ||
macro-paths: ["macros"] | ||
|
||
target-path: "target" | ||
clean-targets: | ||
- "target" | ||
- "dbt_modules" | ||
- "logs" | ||
|
||
require-dbt-version: [">=1.0.0", "<2.0.0"] | ||
|
||
models: | ||
jaffle_shop: | ||
materialized: table | ||
staging: | ||
materialized: view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
with customers as ( | ||
|
||
select * from {{ ref('stg_customers') }} | ||
|
||
), | ||
|
||
orders as ( | ||
|
||
select * from {{ ref('stg_orders') }} | ||
|
||
), | ||
|
||
payments as ( | ||
|
||
select * from {{ ref('stg_payments') }} | ||
|
||
), | ||
|
||
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 | ||
from orders | ||
|
||
group by customer_id | ||
|
||
), | ||
|
||
customer_payments as ( | ||
|
||
select | ||
orders.customer_id, | ||
sum(amount) as total_amount | ||
|
||
from payments | ||
|
||
left join orders on | ||
payments.order_id = orders.order_id | ||
|
||
group by orders.customer_id | ||
|
||
), | ||
|
||
final as ( | ||
|
||
select | ||
customers.customer_id, | ||
customers.first_name, | ||
customers.last_name, | ||
customers.full_name, | ||
customer_orders.first_order, | ||
customer_orders.most_recent_order, | ||
customer_orders.number_of_orders, | ||
customer_payments.total_amount as customer_lifetime_value | ||
|
||
from customers | ||
|
||
left join customer_orders | ||
on customers.customer_id = customer_orders.customer_id | ||
|
||
left join customer_payments | ||
on customers.customer_id = customer_payments.customer_id | ||
|
||
) | ||
|
||
select * from final |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
with customers as ( | ||
|
||
select * from {{ ref('stg_customers', v=1) }} | ||
|
||
), | ||
|
||
orders as ( | ||
|
||
select * from {{ ref('stg_orders') }} | ||
|
||
), | ||
|
||
payments as ( | ||
|
||
select * from {{ ref('stg_payments') }} | ||
|
||
), | ||
|
||
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 | ||
from orders | ||
|
||
group by customer_id | ||
|
||
), | ||
|
||
customer_payments as ( | ||
|
||
select | ||
orders.customer_id, | ||
sum(amount) as total_amount | ||
|
||
from payments | ||
|
||
left join orders on | ||
payments.order_id = orders.order_id | ||
|
||
group by orders.customer_id | ||
|
||
), | ||
|
||
final as ( | ||
|
||
select | ||
customers.customer_id, | ||
customers.first_name, | ||
customers.last_name, | ||
customer_orders.first_order, | ||
customer_orders.most_recent_order, | ||
customer_orders.number_of_orders, | ||
customer_payments.total_amount as customer_lifetime_value | ||
|
||
from customers | ||
|
||
left join customer_orders | ||
on customers.customer_id = customer_orders.customer_id | ||
|
||
left join customer_payments | ||
on customers.customer_id = customer_payments.customer_id | ||
|
||
) | ||
|
||
select * from final |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% docs orders_status %} | ||
|
||
Orders can be one of the following statuses: | ||
|
||
| status | description | | ||
|----------------|------------------------------------------------------------------------------------------------------------------------| | ||
| placed | The order has been placed but has not yet left the warehouse | | ||
| shipped | The order has ben shipped to the customer and is currently in transit | | ||
| completed | The order has been received by the customer | | ||
| return_pending | The customer has indicated that they would like to return the order, but it has not yet been received at the warehouse | | ||
| returned | The order has been returned by the customer and received at the warehouse | | ||
|
||
|
||
{% enddocs %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{% set payment_methods = ['credit_card', 'coupon', 'bank_transfer', 'gift_card'] %} | ||
|
||
with orders as ( | ||
|
||
select * from {{ ref('stg_orders') }} | ||
|
||
), | ||
|
||
payments as ( | ||
|
||
select * from {{ ref('stg_payments') }} | ||
|
||
), | ||
|
||
order_payments as ( | ||
|
||
select | ||
order_id, | ||
|
||
{% for payment_method in payment_methods -%} | ||
sum(case when payment_method = '{{ payment_method }}' then amount else 0 end) as {{ payment_method }}_amount, | ||
{% endfor -%} | ||
|
||
sum(amount) as total_amount | ||
|
||
from payments | ||
|
||
group by order_id | ||
|
||
), | ||
|
||
final as ( | ||
|
||
select | ||
orders.order_id, | ||
orders.customer_id, | ||
orders.order_date, | ||
orders.status, | ||
|
||
{% for payment_method in payment_methods -%} | ||
|
||
order_payments.{{ payment_method }}_amount, | ||
|
||
{% endfor -%} | ||
|
||
order_payments.total_amount as amount | ||
|
||
from orders | ||
|
||
|
||
left join order_payments | ||
on orders.order_id = order_payments.order_id | ||
|
||
) | ||
|
||
select * from final |
Oops, something went wrong.