SnowConvert AI - Oracle - SnowConvert AI Custom UDFs¶
Description¶
Some Oracle built-in functions and functionalities may not be available or may behave differently in Snowflake. To minimize these differences, some functions are replaced with SnowConvert AI Custom UDFs.
These UDFs are automatically created during migration, in the UDF Helper folder, inside the Output folder. There is one file per custom UDF.
BFILENAME UDF¶
Description¶
This function takes the directory name and the file name parameters of the Oracle BFILENAME() as STRING and returns a concatenation of them using \. Since BFILE is translated to VARCHAR, the BFILENAME result is handled as text.
Warning
The \ must be changed to match the corresponding operating system file concatenation character.
Custom UDF overloads¶
BFILENAME_UDF(string, string)¶
It concatenates the directory path and the file name.
Parameters
DIRECTORYNAME: A
STRINGthat represents the directory path.FILENAME: A
STRINGthat represents the file name.
UDF¶
Oracle¶
Result¶
COL1 |
|---|
[BFILE:myfile.png] |
Snowflake¶
Result¶
COL1 |
|---|
mydirectory\myfile.png |
Known Issues¶
1. No access to the DBMS_LOB built-in package¶
Since LOB data types are not supported in Snowflake there is not an equivalent for the DBMS_LOB functions and there are no implemented workarounds yet.
CAST_DATE UDF¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
This custom UDF is added to avoid runtime exceptions caused by format differences when casting strings to DATE, inside procedures and functions.
Custom UDF overloads¶
CAST_DATE_UDF(datestr)¶
It creates a DATE from a STRING.
Parameters
DATESTR: A
STRINGthat represents aDATEwith a specific format.
UDF¶
Oracle¶
Result¶
COL1 |
|---|
1996-03-20 00:00:00.000 |
Snowflake¶
Result¶
COL1 |
|---|
1996-03-20 |
Known Issues¶
1. Oracle DATE contains TIMESTAMP¶
Take into consideration that Oracle DATE contains an empty TIMESTAMP (00:00:00.000), while Snowflake DATE does not. SnowConvert AI allows transforming DATE to TIMESTAMP with the SysdateAsCurrentTimestamp flag.
Related EWIs¶
SSC-FDM-OR0042: Date Type Transformed To Timestamp Has A Different Behavior
DATE_TO_JULIANDAYS_UDF¶
Description¶
The DATE_TO_JULIANDAYS_UDF() function takes a DATE and returns the number of days since January 1, 4712 BC. This function is equivalent to the Oracle TO_CHAR(DATE,’J’)
Custom UDF overloads¶
DATE_TO_JULIANDAYS_UDF(date)¶
Parameters
INPUT_DATE: The
DATEof the operation.
UDF¶
Usage Example¶
Oracle¶
Snowflake¶
Known Issues¶
No issues were found.
Related EWIs¶
SSC-FDM-OR0042: Date Type Transformed To Timestamp Has A Different Behavior
DATEADD UDF¶
Description¶
This UDF is used as a template for all cases when there is an addition between a DATE or TIMESTAMP type and FLOAT type.
Custom UDF overloads¶
DATEADD_UDF(date, float)¶
Parameters
FIRST_PARAM: The first
DATEof the operation.SECOND_PARAM: The
FLOATto be added.
UDF¶
DATEADD_UDF(float, date)¶
Parameters
FIRST_PARAM: The
FLOATto be added.SECOND_PARAM: The
DATEof the operation.
UDF¶
DATEADD_UDF(timestamp, float)¶
Parameters
FIRST_PARAM: The first
TIMESTAMPof the operation.SECOND_PARAM: The
FLOATto be added.
UDF¶
DATEADD_UDF(float, timestamp)¶
Parameters
FIRST_PARAM: The
FLOATof the operation.SECOND_PARAM: The
TIMESTAMPof the operation.
UDF¶
Usage example¶
Oracle¶
Result¶
TO_TIMESTAMP(‘03/08/2009,12:47AM’,’DD/MM/YY,HH:MIAM’)+62.40750856543442 |
|---|
2009-10-04 10:33:49.000 |
Snowflake¶
Result¶
|PUBLIC.DATEADD_UDF(
TO_TIMESTAMP(‘03/08/2009, 12:47 AM’, ‘DD/MM/YY, HH12:MI AM’), 62.40750856543442) |
|---|
2009-10-04 00:47:00.000 |
Known Issues¶
1. Differences in time precision¶
When there are operations between Dates or Timestamps and Floats, the time may differ from Oracle’s. There is an action item to fix this issue.
Related EWIs¶
No EWIs related.
DATEDIFF UDF¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
This UDF is used as a template for all cases when there is a subtraction between a DATE, TIMESTAMP, and any other type (except Intervals).
Custom UDF overloads¶
DATEDIFF_UDF(date, date)¶
Parameters
FIRST_PARAM: The first
DATEof the operation.SECOND_PARAM: The
DATEto be subtracted.
UDF¶
DATEDIFF_UDF(date, timestamp)¶
Parameters
FIRST_PARAM: The first
DATEof the operation.SECOND_PARAM: The
TIMESTAMPto be subtracted.
UDF¶
DATEDIFF_UDF(date, integer)¶
Parameters
FIRST_PARAM: The first
DATEof the operation.SECOND_PARAM: The
INTEGERto be subtracted.
UDF¶
DATEDIFF_UDF(timestamp, timestamp)¶
Parameters
FIRST_PARAM: The first
TIMESTAMPof the operation.SECOND_PARAM: The
TIMESTAMPto be subtracted.
UDF¶
DATEDIFF_UDF(timestamp, date)¶
Parameters
FIRST_PARAM: The first
TIMESTAMPof the operation.SECOND_PARAM: The
DATEto be subtracted.
UDF¶
DATEDIFF_UDF(timestamp, number)¶
Parameters
FIRST_PARAM: The first
TIMESTAMPof the operation.SECOND_PARAM: The
NUMBERto be subtracted.
UDF¶
Usage example¶
Note
The unknown is a column whose type could not be resolved, it could be a timestamp, date integer, or number.
Note
--disableDateAsTimestamp
Flag to indicate whether SYSDATE should be transformed into CURRENT_DATE or CURRENT_TIMESTAMP. This will also affect all DATE columns that will be transformed to TIMESTAMP.
Oracle¶
Snowflake¶
Known Issues¶
1. Functional differences for timestamps¶
Sometimes the Snowflake value returned by the UDF may differ from the Oracle one due to the time. Consider the following example
Oracle¶
Result¶
ASTIMESTAMP-UNKNOWN |
|---|
4417 23:0:0.0 |
Snowflake¶
Result¶
PUBLIC.DATEDIFF_UDF( ASTIMESTAMP, UNKNOWN) |
|---|
4418 |
Related EWIs¶
SSC-EWI-OR0036: Types resolution issues, the arithmetic operation may not behave correctly between string and date.
SSC-FDM-OR0042: Date Type Transformed To Timestamp Has A Different Behavior.
JSON_VALUE UDF¶
Translation reference to convert Oracle JSON_VALUE function to Snowflake
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
As per Oracle’s documentation, this function uses the SQL/JSON Path Expression to request information about a portion of a JSON instance. The returning value is always a scalar value, else the function returns NULL by default.
The JSON_VALUE_UDF is a Snowflake implementation of the JSONPath specification that uses a modified version of the original JavaScript implementation developed by Stefan Goessner.
Sample Source Patterns¶
Setup Data¶
Run these queries to run queries in the JSON_VALUE Patterns section.
Oracle¶
Snowflake¶
JSON_VALUE Patterns¶
Oracle¶
Results¶
JSON Path |
Query result |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Snowflake¶
Results¶
JSON Path |
Query result |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOT SUPPORTED |
|
NOT SUPPORTED |
Known Issues¶
1. Returning Type Clause is not fully supported¶
Now, the only supported types when translating the functionality of the RETURNING TYPE clause are VARCHAR2, CLOB and NUMBER.
For all the other types supported by the original JSON_VALUE function, the JSON_VALUE_UDF will behave as if no RETURNING TYPE clause was specified.
Unsupported types:
DATETIMESTAMP [WITH TIME ZONE]SDO_GEOMETRYCUSTOM TYPE
2. ON MISMATCH Clause is not supported¶
Now, the ON MISMATCH clause is not supported, and a warning EWI is placed instead. Thus, the translated code will behave as if no ON MISMATCH clause was originally specified.
3. Complex filters are not supported¶
Complex filters with more than one expression will return null as they are not supported.
For example, with the same data as before, this JSON path $.store.book[*]?(@.category == "reference").title is supported and will return 'Sayings of the Century'.
However, $.store.book[*]?(@.category == "reference" && @.price < 10).title will return null since more than one expression is used in the filter.
Related EWIs¶
SSC-EWI-0021: Not supported in Snowflake.
JULIAN TO GREGORIAN DATE UDF¶
Description¶
This User Defined Function (UDF) is used to transform or cast the Julian date format to a Gregorian date format. Julian dates can be received in three different formats such as JD Edwards World, astronomy or ordinary format.
Custom UDF overloads¶
JULIAN_TO_GREGORIAN_DATE_UDF(julianDate, formatSelected)¶
It returns a string with the Gregorian date format YYYY-MM-DD.
Parameters:¶
JulianDate: The Julian date to be cast. It can be either CYYDDD (where C is the century) or YYYYDDD.
formatSelected: It represents the format in which the Julian date should be processed. Besides, it is a CHAR and can accept the following formats:
Format available |
Letter representation in CHAR |
Description |
|---|---|---|
Astronomy standardized |
‘J’ |
It is the default format. The cast is based in the expected conversion of the Astronomical Applications Department of the US. The Julian Date format for this is YYYYDDD. |
JD Edwards World |
‘E’ |
The expected Julian date to be received in this case should be CYYDDD (where C represents the century and is operationalized to be added 19 to the corresponding number). |
Ordinal dates |
‘R’ |
The ordinal dates are an arrangement of numbers which represent a concisely date. The format is YYYYDDD and can be easily read because the year part is not mutable. |
UDF¶
Usage Example¶
Oracle¶
Result¶
TO_DATE(‘2020001’, ‘J’) |
|---|
18-JUN-18 |
Formatted result¶
TO_CHAR(TO_DATE(‘2020001’, ‘J’), ‘YYYY-MON-DD’) |
|---|
0818-JUN-18 |
Note: The date must be formatted to visualize all digits of the year.
Snowflake¶
Result¶
JULIAN_TO_GREGORIAN_DATE_UDF(‘2020001’, ‘J’) |
|---|
“0818-06-18” |
Known Issues¶
Any other format: If the Julian Date is formatted in any other not supported format, there would be differences in the output.
Ranges of B.C. dates may represent inconsistencies due to unsupported Snowflake functions for dates.
Related EWIs¶
No EWIs related.
MONTHS BETWEEN UDF [DEPRECATED]¶
Danger
This UDF has been deprecated. Current transformation for Oracle MONTHS_BETWEEN() is Snowflake MONTHS_BETWEEN().
Description¶
MONTHS_BETWEENreturns number of months between datesdate1anddate2. (Oracle MONTHS_BETWEEN SQL Language Reference)
Oracle MONTHS_BETWEEN and Snowflake MONTHS_BETWEEN function, have some functional differences, to minimize these differences and replicate Oracle MONTHS_BETWEEN function better, we added a custom UDF.
Custom UDF overloads¶
MONTHS_BETWEEN_UDF(timestamp_ltz, timestamp_ltz)¶
Parameters
FIRST_DATE: The first
TIMESTAMP_LTZof the operation.SECOND_DATE: The second
TIMESTAMP_LTZof the operation.
UDF¶
Oracle¶
Result¶
MONTHS_BETWEEN(‘2000-03-2022:01:11’,’1996-03-2010:01:11’) |
MONTHS_BETWEEN(‘1996-03-2022:01:11’,’2000-03-2010:01:11’) |
MONTHS_BETWEEN(‘1982-05-1122:31:19’,’1900-01-2515:21:15’) |
MONTHS_BETWEEN(‘1999-12-2501:15:16’,’1900-12-1102:05:16’) |
|---|---|---|---|
48 |
-48 |
987.558021206690561529271206690561529271 |
1188.450492831541218637992831541218637993 |
Snowflake¶
Result¶
MONTHS_BETWEEN_UDF(‘2000-03-20 22:01:11’, ‘1996-03-20 10:01:11’) |
MONTHS_BETWEEN_UDF(‘1996-03-20 22:01:11’, ‘2000-03-20 10:01:11’) |
MONTHS_BETWEEN_UDF(‘1982-05-11 22:31:19’, ‘1900-01-25 15:21:15’) |
MONTHS_BETWEEN_UDF(‘1999-12-25 01:15:16’, ‘1900-12-11 02:05:16’) |
|---|---|---|---|
48.000000 |
-48.000000 |
987.558024 |
1188.450497 |
Known Issues¶
1. Precision may differ from Oracle¶
Some results may differ in the number of decimal digits.
Related EWIs¶
No related EWIs.
REGEXP LIKE UDF¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
REGEXP_LIKEperforms regular expression matching. This condition evaluates strings using characters as defined by the input character set. (Oracle Language Regerence REGEXP_LIKE Condition)
Oracle REGEXP_LIKE and Snowflake REGEXP_LIKE condition, have some functional differences, to minimize these differences and replicate Oracle REGEXP_LIKE function better, we added a custom UDF. The main idea is to escape the backslash symbol from the regular expression where it is required. These are the special characters that need to be escaped when they come with a backslash: 'd', 'D', 'w', 'W', 's', 'S', 'A', 'Z', 'n'. Also, the backreference expression (matches the same text as most recently matched by the “number specified” capturing group) needs to be escaped.
Custom UDF overloads¶
REGEXP_LIKE_UDF(string, string)¶
Parameters¶
COL: is the character expression that serves as the search value.
PATTERN: is the regular expression.
UDF¶
Oracle¶
Snowflake¶
REGEXP_LIKE_UDF(string, string, string)¶
Parameters¶
COL: is the character expression that serves as the search value.
PATTERN: is the regular expression.
MATCHPARAM: is a character expression that let’s change the default matching behavior of the condition. In the following table, there are the Oracle characters with their description and their equivalent in the UDF.
Match Parameter |
Description |
UDF Equivalent |
|---|---|---|
‘i’ |
Specifies case-insensitive matching, even if the determined collation of the condition is case-sensitive. |
‘i’ |
‘c’ |
Specifies case-sensitive and accent-sensitive matching, even if the determined collation of the condition is case-insensitive or accent-insensitive. |
Does not have an equivalent. It is being removed from the parameter.. |
‘n’ |
Allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, then the period does not match the newline character. |
‘s’ |
‘m’ |
Treats the source string as multiple lines. Oracle interprets |
‘m’ |
‘x’ |
Ignores whitespace characters. By default, whitespace characters match themselves. |
Does not have an equivalent. It is being removed from the parameter. |
UDF¶
Oracle¶
Snowflake¶
Known Issues¶
1. UDF match parameter may not behave as expected¶
Due to all the characters available in the Oracle match parameter does not have their equivalent in the user-defined function, the query result may have some functional differences compared to Oracle.
2. UDF pattern parameter does not allow only ‘\’ as a regular expression¶
If as a pattern parameter the regular expression used is only ‘\’ an exception will be thrown like this: JavaScript execution error: Uncaught SyntaxError: Invalid regular expression: //: \ at end of pattern in REGEXP_LIKE_UDF at ‘return COL.match(new RegExp(PATTERN));’ position 17 stackstrace: REGEXP_LIKE_UDF
TIMESTAMP DIFF UDF¶
Description¶
Snowflake does not support the addition operation between TIMESTAMP data types with the - operand. To replicate this functionality, we have added a custom UDF.
Custom UDF overloads¶
TIMESTAMP_DIFF_UDF(timestamp, timestamp)¶
Parameters
LEFT_TS: The first
TIMESTAMPof the operation.RIGHT_TS: The
TIMESTAMPto be added.
UDF¶
Oracle¶
Result¶
COL1-COL2 |
|---|
1461 12:0:0.0 |
-1460 12:0:0.0 |
30056 7:10:4.0 |
36172 23:10:0.0 |
Snowflake¶
Result¶
TIMESTAMP_DIFF_UDF( COL1, COL2) |
|---|
+000001461 12:00:00.00000000 |
-000001460 12:00:00.00000000 |
+000030056 07:10:04.00000000 |
+000036172 23:10:00.00000000 |
Known Issues¶
1. TIMESTAMP format may differ from Oracle¶
The TIMESTAMP format may differ from Oracle, please consider the TIMESTAMP_OUTPUT_FORMAT setting when working with TIMESTAMP data types.
Related EWIs¶
No related EWIs.
TRUNC (date) UDF¶
Description¶
The
TRUNC(date) function returnsdatewith the time portion of the day truncated to the unit specified by the format modelfmt. (Oracle TRUNC(date) SQL Language Reference)
Oracle TRUNC and Snowflake TRUNC function with date arguments have some functional differences.
TRUNC_UDF helper will be added to handle the following cases:
1. The format is not supported by Snowflake.
2. The format exists in Snowflake but works differently.
3. The tool cannot determine the datatype of the first argument.
4. The format is provided as a column or expression and not as a literal.
Custom UDF overloads¶
TRUNC_UDF(date)¶
It applies an explicit DATE cast to the input Timestamp.
Parameters
INPUT: The Timestamp with Time Zone (TIMESTAMP_LTZ) that needs to be truncated.
Warning
The default parameter for the UDF is TIMESTAMP_LTZ. It may need to be changed to TIMESTAMP_TZ or TIMESTAMP_NTZ to match the default TIMESTAMP used by the user.
UDF¶
Oracle¶
Result¶
Date |
|---|
1996-03-20 00:00:00.000 |
Snowflake¶
Result¶
DATE |
|---|
1996-03-20 |
TRUNC_UDF(date, fmt)¶
Manually creates a new date using DATE_FROM_PARTS() function, depending on the format category used.
Parameters
DATE_TO_TRUNC: The Timestamp with Time Zone (TIMESTAMP_LTZ) that needs to be truncated.
DATE_FMT: The date format as a VARCHAR. Same formats that are supported in Oracle.
Warning
The default parameter for the UDF is TIMESTAMP_LTZ. It may need to be changed to TIMESTAMP_TZ or TIMESTAMP_NTZ to match the default TIMESTAMP used by the user.
UDF¶
TRUNC format scenarios¶
Warning
The results format depends on the DateTime output formats configurated for the database.
1. Natively supported formats¶
Oracle¶
Result¶
TRUNC(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’),’YYYY’) |
|---|
01-JAN-22 |
01-JAN-22 |
01-JAN-22 |
01-JAN-22 |
01-JAN-22 |
01-APR-22 |
01-APR-22 |
01-APR-22 |
01-APR-22 |
20-APR-22 |
20-APR-22 |
20-APR-22 |
Snowflake¶
Result¶
TRUNC(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’),’YYYY’) |
|---|
2022-01-01 |
2022-01-01 |
2022-01-01 |
2022-01-01 |
2022-01-01 |
2022-04-01 |
2022-04-01 |
2022-04-01 |
2022-04-01 |
2022-04-20 |
2022-04-20 |
2022-04-20 |
2. Formats mapped to another format¶
Oracle¶
Result¶
TRUNC(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’)) |
|---|
20-APR-22 |
01-JAN-22 |
01-JAN-22 |
01-APR-22 |
18-APR-22 |
20-APR-22 |
20-APR-22 |
20-APR-22 |
20-APR-22 |
Snowflake¶
Result¶
TRUNC(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’), ‘DD’) |
|---|
2022-04-20 |
2022-01-01 |
2022-01-01 |
2022-04-01 |
2022-04-18 |
2022-04-20 |
2022-04-20 |
2022-04-20 |
2022-04-20 |
3. Day formats¶
Oracle¶
Result¶
TRUNC(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’),’DAY’) |
|---|
17-APR-22 |
17-APR-22 |
17-APR-22 |
Snowflake¶
Result¶
TRUNC_UDF(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’),’DAY’) |
|---|
2022-04-17 |
2022-04-17 |
2022-04-17 |
4. Unsupported formats¶
Oracle¶
Result¶
TRUNC(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’),’CC’) |
|---|
01-JAN-01 |
01-JAN-01 |
03-JAN-22 |
03-JAN-22 |
03-JAN-22 |
16-APR-22 |
15-APR-22 |
Snowflake¶
Result¶
TRUNC_UDF(TO_DATE(‘20/04/2022 13:21:10’,’DD/MM/YYYY HH24:MI:SS’),’CC’) |
|---|
2001-01-01 |
2001-01-01 |
2022-01-03 |
2022-01-03 |
2022-01-03 |
2022-04-16 |
2022-04-15 |
Note
When the TRUNC function is used with an unsupported format or a parameter that cannot be handled by SnowConvert AI. To avoid any issues, the format is replaced with a valid format, or TRUNC_UDF is added.
Known Issues¶
1. Oracle DATE contains TIMESTAMP¶
Take into consideration that Oracle DATE contains an empty TIMESTAMP (00:00:00.000), while Snowflake DATE does not.
Related EWIs¶
No related EWIs.
TRUNC (number) UDF¶
Description¶
The
TRUNC(number) function returnsn1truncated ton2decimal places. Ifn2is omitted, thenn1is truncated to 0 places.n2can be negative to truncate (make zero)n2digits left of the decimal point. (Oracle TRUNC(number) SQL Language Reference)
TRUNC_UDF for numeric values will be added to handle cases where the first column has an unrecognized data type.
Example:
If the definition of column1 was not provided to the tool. Then the TRUNC_UDF will be added and in execution time, the overload of TRUNC_UDF will handle the case if it is a numeric or a date type.
Please refer to TRUNC (DATE) section.
The following sections provide the proof that TRUNC_UDF will handle perfectly numeric values.
Custom UDF overloads¶
TRUNC_UDF(n1)¶
It calls Snowflake TRUNC function with the input number. This overload exists to handle the different types of parameter scenarios, in case that information is not available during the migration.
Parameters
INPUT: The
NUMBERthat needs to be truncated.
UDF¶
Oracle¶
Result¶
TRUNC(1.000001) |
TRUNC(15.79) |
TRUNC(-975.975) |
TRUNC(135.135) |
|---|---|---|---|
1 |
15 |
-975 |
135 |
Snowflake¶
Result¶
TRUNC_UDF(1.000001) |
TRUNC_UDF(15.79) |
TRUNC_UDF(-975.975) |
TRUNC_UDF(135.135) |
|---|---|---|---|
1 |
15 |
-975 |
135 |
TRUNC_UDF(n1, n2)¶
It calls Snowflake TRUNC function with the input number and the scale. This overload exists to handle the different types of parameter scenarios, in case that information is not available during the migration.
Parameters
INPUT: The
NUMBERthat needs to be truncated.SCALE: Represents the number of digits the output will include after the decimal point.
UDF¶
Oracle¶
Result¶
TRUNC(1.000001,-2) |
TRUNC(1.000001,-1) |
TRUNC(1.000001,0) |
TRUNC(1.000001,1) |
TRUNC(1.000001,2) |
TRUNC(15.79,-2) |
TRUNC(15.79,-1) |
TRUNC(15.79,0) |
TRUNC(15.79,1) |
TRUNC(15.79,50) |
TRUNC(-9.6,-2) |
TRUNC(-9.6,-1) |
TRUNC(-9.6,0) |
TRUNC(-9.6,1) |
TRUNC(-9.6,2) |
TRUNC(-975.975,-3) |
TRUNC(-975.975,-2) |
TRUNC(-975.975,-1) |
TRUNC(-975.975,0) |
TRUNC(-975.975,1) |
TRUNC(-975.975,2) |
TRUNC(-975.975,3) |
TRUNC(-975.975,5) |
TRUNC(135.135,-10) |
TRUNC(135.135,-2) |
TRUNC(135.135,0) |
TRUNC(135.135,1) |
TRUNC(135.135,2) |
TRUNC(135.135,3) |
TRUNC(135.135,5) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 |
0 |
1 |
1 |
1 |
0 |
10 |
15 |
15.7 |
15.79 |
0 |
0 |
-9 |
-9.6 |
-9.6 |
0 |
-900 |
-970 |
-975 |
-975.9 |
-975.97 |
-975.975 |
-975.975 |
0 |
100 |
135 |
135.1 |
135.13 |
135.135 |
135.135 |
Snowflake¶
Result¶
TRUNC_UDF ( 1.000001, -2 ) |
TRUNC_UDF ( 1.000001, -1 ) |
TRUNC_UDF ( 1.000001, 0 ) |
TRUNC_UDF ( 1.000001, 1 ) |
TRUNC_UDF ( 1.000001, 2 ) |
TRUNC_UDF ( 15.79, -2) |
TRUNC_UDF ( 15.79, -1) |
TRUNC_UDF ( 15.79, 0) |
TRUNC_UDF ( 15.79, 1 ) |
TRUNC_UDF ( 15.79, 50 ) |
TRUNC_UDF ( -9.6, -2 ) |
TRUNC_UDF ( -9.6, -1 ) |
TRUNC_UDF ( -9.6, 0 ) |
TRUNC_UDF ( -9.6, 1 ) |
TRUNC_UDF ( -9.6, 2 ) |
TRUNC_UDF ( -975.975, -3 ) |
TRUNC_UDF ( -975.975, -2 ) |
TRUNC_UDF ( -975.975, -1 ) |
TRUNC_UDF ( -975.975, 0 ) |
TRUNC_UDF ( -975.975, 1 ) |
TRUNC_UDF ( -975.975, 2 ) |
TRUNC_UDF ( -975.975, 3 ) |
TRUNC_UDF ( -975.975, 5 ) |
TRUNC_UDF ( 135.135, -10 ) |
TRUNC_UDF ( 135.135, -2 ) |
TRUNC_UDF ( 135.135, 0 ) |
TRUNC_UDF ( 135.135, 1 ) |
TRUNC_UDF ( 135.135, 2 ) |
TRUNC_UDF ( 135.135, 3 ) |
TRUNC_UDF ( 135.135, 5 ) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 |
0 |
1 |
1.0 |
1.00 |
0 |
10 |
15 |
15.7 |
15.79 |
0 |
0 |
-9 |
-9.6 |
-9.6 |
0 |
-900 |
-970 |
-975 |
-975.9 |
-975.97 |
-975.975 |
-975.975 |
0 |
100 |
135 |
135.1 |
135.13 |
135.135 |
135.135 |
Known Issues¶
No issues were found.
Related EWIs¶
No related EWIs.
SnowConvert AI - Oracle - INTERVAL UDFs¶
Necessary code to run INTERVAL UDFs¶
To run any of the interval UDFs, it is necessary to run the following code before:
DATEADD UDF INTERVAL¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
This UDF is used to resolve operations with intervals like:
INTERVAL + DATE
INTERVAL + TIMESTAMP
DATE + INTERVAL
DATE + TIMESTAMP
INTERVAL + UNKNOWN
UNKNOWN + INTERVAL
Note
An UNKNOWN type is a column or expression whose type could not be resolved by Snow Convert, it tends to happen when the DDLs for tables are not included in the migration or when there is an expression or subquery that can return different data types.
Custom UDF overloads¶
DATEADD_UDF(string, date)¶
Parameters
INTERVAL_VALUE: The interval
Stringof the operation.D: The
DATEwhere the interval will be added.
UDF¶
DATEADD_UDF(date, string)¶
Parameters
D: The
DATEwhere the interval will be added.INTERVAL_VALUE: The interval
Stringof the operation.
UDF¶
DATEADD_UDF(string, timestamp)¶
Parameters
INTERVAL_VALUE: The interval
Stringof the operation.D: The
TIMESTAMPwhere the interval will be added.
UDF¶
DATEADD_UDF(timestamp, string)¶
Parameters
D: The
TIMESTAMPwhere the interval will be added.INTERVAL_VALUE: The interval
Stringof the operation.
UDF¶
Usage example¶
Note
--disableDateAsTimestamp
Flag to indicate whether SYSDATE should be transformed into CURRENT_DATE or CURRENT_TIMESTAMP. This will also affect all DATE columns that will be transformed to TIMESTAMP.
Oracle¶
Results¶
Snowflake¶
Note
This configuration was used in Snowflake
Results¶
Known Issues¶
1. INTERVAL + INTERVAL Operation is not supported¶
Snowflake does not support INTERVAL + INTERVAL operations.
Related EWIs¶
SSC-EWI-OR0036: Types resolution issues, the arithmetic operation may not behave correctly between string and date.
SSC-EWI-OR0095: Operation Between Interval Type and Date Type not Supported.
SSC-FDM-0007: Element with missing dependencies.
SSC-FDM-OR0042: Date Type Transformed To Timestamp Has A Different Behavior.
DATEDIFF UDF INTERVAL¶
Note
Some parts in the output code are omitted for clarity reasons.
Description¶
This UDF is used to resolve operations with intervals like:
INTERVAL - UNKNOWN
UNKNOWN - INTERVAL
DATE - INTERVAL
TIMESTAMP - INTERVAL
Note
An UNKNOWN type is a column or expression whose type could not be resolved by Snow Convert, it tends to happen when the DDLs for tables are not included in the migration or when there is an expression or subquery that can return different data types.
Custom UDF overloads¶
DATEADD_DDIF(string, date)¶
Parameters
INTERVAL_VALUE: The interval
Stringof the operation.D: The
DATEwhere the interval will be subtracted.
UDF¶
DATEADD_DIFF(date, string)¶
Parameters
D: The
DATEwhere the interval will be subtracted.INTERVAL_VALUE: The interval
Stringof the operation.
UDF¶
DATEADD_DIFF(string, timestamp)¶
Parameters
INTERVAL_VALUE: The interval
Stringof the operation.D: The
TIMESTAMPwhere the interval will be subtracted.
UDF¶
DATEADD_DIFF(timestamp, string)¶
Parameters
D: The
TIMESTAMPwhere the interval will be subtracted.INTERVAL_VALUE: The interval
Stringof the operation.
UDF¶
Usage example¶
Note
--disableDateAsTimestamp
Flag to indicate whether SYSDATE should be transformed into CURRENT_DATE or CURRENT_TIMESTAMP. This will also affect all DATE columns that will be transformed to TIMESTAMP.
Oracle¶
Result¶
Snowflake¶
Note
This configuration was used in Snowflake
Result¶
Known Issues¶
1. INTERVAL - INTERVAL Operation is not supported¶
Snowflake does not support INTERVAL - INTERVAL operations.
Related EWIs¶
SSC-EWI-OR0036: Types resolution issues, the arithmetic operation may not behave correctly between string and date.
SSC-EWI-OR0095: Operation Between Interval Type and Date Type not Supported.
SSC-FDM-0007: Element with missing dependencies.
SSC-FDM-OR0042: Date Type Transformed To Timestamp Has A Different Behavior.