From 002eadc362aea722669eb9eac11e62068b8d6fb1 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Mon, 14 Oct 2024 11:37:37 +0200 Subject: [PATCH] add table alias optional argument to macro --- macros/unix_ms_timestamp_to_utc.sql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macros/unix_ms_timestamp_to_utc.sql b/macros/unix_ms_timestamp_to_utc.sql index e342ecd..2ea223a 100644 --- a/macros/unix_ms_timestamp_to_utc.sql +++ b/macros/unix_ms_timestamp_to_utc.sql @@ -9,6 +9,14 @@ It generates two output fields: This macro is intended to be used within a SELECT statement and ensures that the output is properly formatted for further analysis. */ -{% macro unix_ms_timestamp_to_utc(column_name) %} - to_timestamp({{ adapter.quote(column_name) }} / 1000) at time zone 'UTC' +{% macro unix_ms_timestamp_to_utc(column_name, table_alias=None) %} + {%- if table_alias -%} + to_timestamp( + {{ adapter.quote(table_alias) }}.{{ adapter.quote(column_name) }} / 1000 + ) at time zone 'UTC' + {%- else -%} + to_timestamp({{ adapter.quote(column_name) }} / 1000) at time zone 'UTC' + + {%- endif -%} + {% endmacro %}