Skip to content

Commit

Permalink
add macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Bethany Hipple committed Apr 3, 2024
1 parent 96c8281 commit b3cf27c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_modules"

vars:
the_distant_future: '2099-12-31'

# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models
Expand Down
5 changes: 5 additions & 0 deletions macros/cents_to_dollars.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% macro cents_to_dollars(column_name, scale=2) %}

({{ column_name }} / 100)::numeric(16, {{ scale }})

{% endmacro %}
2 changes: 1 addition & 1 deletion models/staging/jaffle_shop/_schema_jaffle_shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ models:
values:
- "returned"
- "completed"
- "pending"
- "return_pending"
- "placed"
- "shipped"
- name: stg_jaffle_shop__products
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stripe/stg_stripe__payment.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source as (
renamed as (

select
amount,
{{ cents_to_dollars('amount') }} as amount_usd,
created,
id,
orderid,
Expand Down

0 comments on commit b3cf27c

Please sign in to comment.