Skip to content

Commit

Permalink
fix(postgres cents_to_dollars macro): Postgres needs special syntax
Browse files Browse the repository at this point in the history
Postgres needs a little bit of special sauce to properly pad zeros to 2 decimals in the `cents_to_dollars` macro.
  • Loading branch information
gwenwindflower committed Apr 18, 2024
1 parent c708c01 commit 13f0b77
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions macros/cents_to_dollars.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
({{ column_name }} / 100)::numeric(16, 2)
{%- endmacro %}

{% macro postgres__cents_to_dollars(column_name) -%}
({{ column_name }}::numeric(16, 2) / 100)
{%- endmacro %}

{% macro bigquery__cents_to_dollars(column_name) %}
round(cast(({{ column_name }} / 100) as numeric), 2)
{% endmacro %}

0 comments on commit 13f0b77

Please sign in to comment.