add table alias optional argument to macro

This commit is contained in:
Pablo Martin 2024-10-14 11:37:37 +02:00
parent c0718daaa9
commit 002eadc362

View file

@ -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) %}
{% 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 %}