Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result of the dbt_date.convert_timestamp() is always timestamp_ntz #125

Closed
ImBharathwaj opened this issue May 16, 2024 · 3 comments
Closed

Comments

@ImBharathwaj
Copy link

Result I got

I was using dbt_date.convert_timezone() which result an outcome with timestamp without time zone offset in the form of timestamp_ntz

Result I am looking for

I am looking to get the outcome in the form of timestamp_tz with time zone offset

I have tried every possible things which I could do. But nothing was working
Please let me know any other possible ways

@clausherther
Copy link
Contributor

Which database platform are you using, and which version of dbt-date and dbt?

@ImBharathwaj
Copy link
Author

I am using snowflake as data warehouse, dbt version as 1.7.3 with snowflake plugin version as 1.7.1
I need to store timestamp data in various formats and data-types liKkeVARCHAR, TIMESTAMP_TZ, TIMESTAMP.NTZ) as a datatype of TIMESTAMP_TZ with timezone in the form of UTC with offset of +0000

Please let me know the feasibility of the my requirement.

@clausherther
Copy link
Contributor

In dbt-date, we cast the result of convert_timezone to whatever data type dbt.type_timestamp() returns on the platform, which on Snowflake is timestamp_ntz.

{% macro default__convert_timezone(column, target_tz, source_tz) -%}
convert_timezone('{{ source_tz }}', '{{ target_tz }}',
    cast({{ column }} as {{ dbt.type_timestamp() }})
)
{%- endmacro -%}

If you're on Snowflake, have you tried just using convert_timezone directly, without dbt-date?
https://docs.snowflake.com/en/sql-reference/functions/convert_timezone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants