From 13f0b77f2b75ee23df1ab1b02e560db25d2760fe Mon Sep 17 00:00:00 2001 From: gwen windflower Date: Thu, 18 Apr 2024 11:37:13 -0500 Subject: [PATCH] fix(postgres cents_to_dollars macro): Postgres needs special syntax Postgres needs a little bit of special sauce to properly pad zeros to 2 decimals in the `cents_to_dollars` macro. --- macros/cents_to_dollars.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/macros/cents_to_dollars.sql b/macros/cents_to_dollars.sql index 681afd00..3593a3fb 100644 --- a/macros/cents_to_dollars.sql +++ b/macros/cents_to_dollars.sql @@ -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 %}