diff --git a/models/orders.sql b/models/orders.sql index cbb293491..46e0ae9f7 100644 --- a/models/orders.sql +++ b/models/orders.sql @@ -36,6 +36,7 @@ final as ( orders.customer_id, orders.order_date, orders.status, + orders.is_closed, {% for payment_method in payment_methods -%} diff --git a/models/staging/stg_orders.sql b/models/staging/stg_orders.sql index 3d48d39b8..0753775c2 100644 --- a/models/staging/stg_orders.sql +++ b/models/staging/stg_orders.sql @@ -13,9 +13,13 @@ renamed as ( select id as order_id, user_id as customer_id, - order_date, - status - + order_date, + status, + case + when status IN ('completed', 'returned') THEN true + when status IN ('shipped', 'placed', 'return_pending') THEN false + else NULL + end as is_closed from source )