Feat(trino): Introduce custom timestamp type mapping #5635
+322
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
for Trino.
Delta Lake has two timestamp types: a time zone aware type
TIMESTAMPand a time zone unaware typeTIMESTAMPNTZ. These map to Trino'sTIMESTAMP(3) WITH TIMEZONEandTIMESTAMP(6)respectively. See the Trino docs here. Therefore, SQLMesh will use one of those types for timestamps when generating Trino DDL statements with Delta Lake. Which one used depends on whether the column is time zone aware. This PR allows users to customize this mapping with the introduction of atimestamp_mappingmap in the Trino engine adapter. Columns re-mapped this way will skip the automatic re-mapping done by SQLMesh mentioned above.Hopefully the following example will help clarify my point. If you have a Trino model with a
TIMESTAMPcolumn, the table's column will be of typeTIMESTAMP(6)because Trino'sTIMESTAMPis time zone unaware. If you want the column to beTIMESTAMP(3) WITH TIMEZONEinstead ofTIMESTAMP(6), you can add this mapping to your Trino engine adapter config: