Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ models:
data_tests:
- accepted_values:
values: ['completed', 'pending', 'cancelled', 'shipped', 'processing', 'return_pending']
- name: tax_amount
description: Estimated tax at 8% of order total
- name: gross_total
description: Order total + shipping + tax - discounts

- name: stg_jaffle_shop__order_items
description: Order line items with calculated line totals
Expand All @@ -39,12 +43,14 @@ models:
description: Quantity * unit price

- name: stg_stripe__payments
description: Payment transactions with risk scoring
description: Payment transactions with risk scoring (test transactions excluded)
columns:
- name: payment_id
data_tests:
- unique
- not_null
- name: currency
description: Payment currency (defaults to USD)
- name: payment_status
data_tests:
- accepted_values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ cleaned as (
coalesce(order_total, 0) as order_total,
coalesce(shipping_cost, 0) as shipping_cost,
coalesce(discount_amount, 0) as discount_amount,
round(coalesce(order_total, 0) * 0.08, 2) as tax_amount,
coalesce(order_total, 0)
+ coalesce(shipping_cost, 0)
+ round(coalesce(order_total, 0) * 0.08, 2)
- coalesce(discount_amount, 0) as gross_total,
coupon_code,
created_at,
updated_at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cleaned as (
order_id,
payment_method,
amount as payment_amount,
'USD' as currency,
status as payment_status,
created_at as payment_created_at,
card_last_four,
Expand All @@ -18,6 +19,7 @@ cleaned as (
from source
where id is not null
and amount > 0
and billing_email not like '%@test.com'
)

select * from cleaned
Loading