Operation Between Interval Type and Date Type not Supported
Severity
Low
Description
INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND are not a supported data type, they are transformed to VARCHAR(20). Therefore all arithmetic operations between Date Types and the original Interval Type Columns are not supported.
Furthermore, operations between an Interval Type and Date Type (in this order) are not supported in Snowflake; and these operations use this EWI as well.
Example Code
Input Code:
IN -> Oracle_01.sql
CREATETABLEtable_with_intervals( date_col DATE, time_col TIMESTAMP, intervalYearToMonth_col INTERVAL YEARTOMONTH, intervalDayToSecond_col INTERVAL DAYTOSECOND);-- Date + Interval Y to MSELECT date_col + intervalYearToMonth_col FROM table_with_intervals;-- Date - Interval D to SSELECT date_col - intervalDayToSecond_col FROM table_with_intervals;-- Timestamp + Interval D to SSELECT time_col + intervalDayToSecond_col FROM table_with_intervals;-- Timestamp - Interval Y to MSELECT time_col - intervalYearToMonth_col FROM table_with_intervals;
Output Code:
OUT -> Oracle_01.sql
CREATE OR REPLACETABLEtable_with_intervals ( date_col TIMESTAMP/*** SSC-FDM-OR0042 - DATE TYPE COLUMN HAS A DIFFERENT BEHAVIOR IN SNOWFLAKE. ***/, time_col TIMESTAMP(6), intervalYearToMonth_col VARCHAR(20) !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - INTERVAL YEAR TO MONTH DATA TYPE CONVERTED TO VARCHAR ***/!!!,
intervalDayToSecond_col VARCHAR(20) !!!RESOLVE EWI!!! /*** SSC-EWI-0036 - INTERVAL DAY TO SECOND DATA TYPE CONVERTED TO VARCHAR ***/!!!
) COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},"attributes":{"component":"oracle"}}'
;-- Date + Interval Y to MSELECT !!!RESOLVE EWI!!! /*** SSC-EWI-OR0095 - OPERATION BETWEEN INTERVAL TYPE AND DATE TYPE NOT SUPPORTED ***/!!! date_col + intervalYearToMonth_col FROM
table_with_intervals;-- Date - Interval D to SSELECT !!!RESOLVE EWI!!! /*** SSC-EWI-OR0095 - OPERATION BETWEEN INTERVAL TYPE AND DATE TYPE NOT SUPPORTED ***/!!! date_col - intervalDayToSecond_col FROM
table_with_intervals;-- Timestamp + Interval D to SSELECT !!!RESOLVE EWI!!! /*** SSC-EWI-OR0095 - OPERATION BETWEEN INTERVAL TYPE AND DATE TYPE NOT SUPPORTED ***/!!! time_col + intervalDayToSecond_col FROM
table_with_intervals;-- Timestamp - Interval Y to MSELECT !!!RESOLVE EWI!!! /*** SSC-EWI-OR0095 - OPERATION BETWEEN INTERVAL TYPE AND DATE TYPE NOT SUPPORTED ***/!!! time_col - intervalYearToMonth_col FROM
table_with_intervals;
Recommendations
Implement the UDF to simulate the Oracle behavior.
Extract the already transformed value that was stored in the column during migration, and use it as a Snowflake Interval Constantwhen possible.