Skip to content

Commit

Permalink
Add is_closed column in the orders table
Browse files Browse the repository at this point in the history
Signed-off-by: popcorny <[email protected]>
  • Loading branch information
popcornylu committed Jan 10, 2025
1 parent 8d75fcf commit ef6b13f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion models/orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ final as (
orders.customer_id,
orders.order_date,
orders.status,
orders.is_closed,

{% for payment_method in payment_methods -%}

Expand All @@ -50,7 +51,7 @@ final as (

left join order_payments
on orders.order_id = order_payments.order_id

where is_closed = true
)

select * from final
13 changes: 9 additions & 4 deletions models/staging/stg_orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ renamed as (
id as order_id,
user_id as customer_id,
order_date,
status

status,
from source

)

select * from renamed
select *,
case
when status IN ('completed', 'returned') THEN true
when status IN ('shipped', 'placed', 'return_pending') THEN false
else NULL
end as is_closed

from renamed

0 comments on commit ef6b13f

Please sign in to comment.