-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle variants during knowledge graph construction and scope g…
…raph to node, add example prefix in config block
- Loading branch information
Showing
5 changed files
with
109 additions
and
15 deletions.
There are no files selected for viewing
Binary file not shown.
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,60 @@ | ||
{{ config( | ||
dbt_osmosis_prefix="o_", | ||
) }} | ||
|
||
{% 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 as o_order_id, | ||
orders.customer_id as o_customer_id, | ||
orders.order_date as o_order_date, | ||
orders.status as o_status, | ||
|
||
{% for payment_method in payment_methods %} | ||
|
||
order_payments.{{ payment_method }}_amount as o_{{ payment_method }}_amount, | ||
|
||
{% endfor -%} | ||
|
||
order_payments.total_amount as o_amount | ||
|
||
from orders | ||
|
||
|
||
left join order_payments | ||
on orders.order_id = order_payments.order_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
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