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

fixing linting #2

Merged
merged 1 commit into from
Nov 4, 2023
Merged
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
8 changes: 5 additions & 3 deletions models/marts/customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ order_summary as (
sum(orders.order_total) as lifetime_spend

from orders_table as orders

left join order_items_table as order_items on orders.order_id = order_items.order_id


left join
order_items_table as order_items
on orders.order_id = order_items.order_id

group by 1

),
Expand Down
30 changes: 16 additions & 14 deletions models/marts/order_items.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
with
with

order_items as (

Expand All @@ -8,8 +8,8 @@ order_items as (


orders as (
select * from {{ ref('stg_orders')}}

select * from {{ ref('stg_orders') }}
),

products as (
Expand All @@ -20,19 +20,19 @@ products as (

supplies as (

select * from {{ ref('stg_supplies') }}
select * from {{ ref('stg_supplies') }}

),

order_supplies_summary as (

select
product_id,
sum(supply_cost) as supply_cost
select
product_id,
sum(supply_cost) as supply_cost

from supplies
from supplies

group by 1
group by 1
),

joined as (
Expand All @@ -46,12 +46,14 @@ joined as (

from order_items

left join orders on order_items.order_id = orders.order_id
left join orders on order_items.order_id = orders.order_id

left join products on order_items.product_id = products.product_id

left join order_supplies_summary on order_items.product_id = order_supplies_summary.product_id


left join
order_supplies_summary
on order_items.product_id = order_supplies_summary.product_id

)

select * from joined
26 changes: 14 additions & 12 deletions models/marts/orders.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
with
with

orders as (
select * from {{ ref('stg_orders')}}

select * from {{ ref('stg_orders') }}

),

order_items_table as (
select * from {{ ref('order_items')}}

select * from {{ ref('order_items') }}

),

Expand All @@ -18,9 +18,9 @@ order_items_summary as (

order_items.order_id,

sum(supply_cost) as order_cost,
sum(is_food_item) as count_food_items,
sum(is_drink_item) as count_drink_items
sum(order_items.supply_cost) as order_cost,
sum(order_items.is_food_item) as count_food_items,
sum(order_items.is_drink_item) as count_drink_items


from order_items_table as order_items
Expand All @@ -34,13 +34,15 @@ compute_booleans as (
select

orders.*,
order_cost,
count_food_items > 0 as is_food_order,
count_drink_items > 0 as is_drink_order,
order_cost
count_drink_items > 0 as is_drink_order

from orders

left join order_items_summary on orders.order_id = order_items_summary.order_id

left join
order_items_summary
on orders.order_id = order_items_summary.order_id
)

select * from compute_booleans
2 changes: 1 addition & 1 deletion models/staging/stg_locations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ renamed as (
tax_rate,

---------- timestamps
{{dbt.date_trunc('day', 'opened_at')}} as opened_at
{{ dbt.date_trunc('day', 'opened_at') }} as opened_at

from source

Expand Down
1 change: 0 additions & 1 deletion models/staging/stg_order_items.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

with

source as (
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stg_orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ renamed as (
(tax_paid / 100.0) as tax_paid,

---------- timestamps
{{dbt.date_trunc('day','ordered_at')}} as ordered_at
{{ dbt.date_trunc('day','ordered_at') }} as ordered_at

from source

Expand Down
Loading