Translation specification for the transformation of casts to the INTERVAL datatype to Snowflake
Description
Snowflake does not support the Interval data type, but it has INTERVAL constants that can be used in DateTime operations and other uses can be emulated using VARCHAR, SnowConvert will transform CAST functions to the INTERVAL datatype into an equivalent depending on the case:
When the value being casted is of type interval an UDF will be generated to produce the new interval equivalent as a string
When the value is a literal, an Snowflake interval constant will be generated if the cast is used in a datetime operation, otherwise a literal string will be generated
When the value is non-literal then a cast to string will be generated
Sample Source Patterns
Non-interval literals
Teradata
IN -> Teradata_01.sql
SELECTTIMESTAMP'2022-10-15 10:30:00'+CAST ('12:34:56.78'AS INTERVAL HOUR(2) TOSECOND(2)) AS VARCHAR_TO_INTERVAL,TIMESTAMP'2022-10-15 10:30:00'+CAST(-5AS INTERVAL YEAR(4)) AS NUMBER_TO_INTERVAL,CAST('07:00'AS INTERVAL HOUR(2) TOMINUTE) AS OUTSIDE_DATETIME_OPERATION;