[Feature] standardize the dbt.type_timestamp
macro
#9790
Replies: 5 comments
-
Thanks for reaching out about this @fivetran-reneeli 🧠 What are the use-case(s) that you are trying to solve for? Is it doing casts like the following or something else?
Short storyOur docs state that
So even though it is inconvenient that it is not standardized across adapters, this is known and documented behavior rather than a bug.
We don't currently have plans to standardize this. Longer storyHere are some other issues/comments that may be related:
Possibility: a new
|
Database | Naive timestamp data type |
---|---|
Starburst/Trino | TIMESTAMP WITHOUT TIME ZONE |
Athena | TIMESTAMP WITHOUT TIME ZONE |
Postgres | TIMESTAMP |
Redshift | TIMESTAMP |
AlloyDB | TIMESTAMP |
Dremio | TIMESTAMP |
Oracle | TIMESTAMP |
Snowflake | TIMESTAMP_NTZ |
Spark SQL | TIMESTAMP_NTZ |
Databricks | TIMESTAMP_NTZ |
BigQuery | DATETIME |
Teradata | N/A |
Caveats
- This is based off reading the documentation for each database; I didn't actually try them out to double-check each.
TIMESTAMP_NTZ
is not available until Spark 3.4 & Databricks Runtime 13 [1, 2]- Teradata has separate
TIMESTAMP
andTIMESTAMP WITH TIME ZONE
data types, but the former is described as "non-ANSI standard. Analytics Database stores a TIMESTAMP value in UTC." [3]
Beta Was this translation helpful? Give feedback.
-
Thanks for the thorough response @dbeatty10 ! It was helpful to have the related issues-- I found this one to be very in line with extra attention on your comment here.
For more context, on our side our models leverage dbt.type_timestamp for the following warehouses: So like you listed, I believe each one has default TNZ except for BigQuery, where The dbt team may have discussed this in the past, based on comments I found like this. And I dug around the old dbt_utils changelog and saw that the timestamp macro for redshift and postgres were explicitly cast once upon a time. |
Beta Was this translation helpful? Give feedback.
-
@fivetran-reneeli All those links you included are golden info 🤩
Could you share more about how you are leveraging The reason I ask is there are at least a few different uses I can think of:
|
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay! Sure thing, so our team develops data model packages that we make compatible with dbt, that are warehouse-agnostic (so currently the packages work across postgres, snowflake, bigquery, redshift, and databricks). Here is an example model with jira.
Because we want our models to work with all those mentioned warehouses, ideally the compiled code is the same for all. |
Beta Was this translation helpful? Give feedback.
-
No prob and thanks for that example @fivetran-reneeli ! There's some tricky things to consider here. For example, how would this example behave when We took a look at something similar a year or so ago when considering #5969, and we opted not to tackle it at that time due to the complexity of getting it right and the high probability of accidentally getting it wrong and creating churn for users and maintainers. See #5935 and #7665 for a small sample of edge cases related to aware vs. naive that we've run into. So I'm going to upgrade this issue to a Discussion so we can further discuss different design aspirations folks are looking for as well as edge cases people have come across. I'd propose the main topic of the discussion to be this question:
|
Beta Was this translation helpful? Give feedback.
-
Is this a new bug in dbt-core?
Current Behavior
Not sure if this is a bug, but I am wondering if there are plans to standardize the
dbt.type_timestamp
macro. I believe in most warehouses, it defaults to timestamp without timezone, so it would be helpful to confirm that this is the end result across all adapters.Expected Behavior
Field is a timestamp without time zone
Steps To Reproduce
n/a
Relevant log output
Environment
Which database adapter are you using with dbt?
other (mention it in "Additional Context")
Additional Context
Using multiple adapters
Beta Was this translation helpful? Give feedback.
All reactions