MSCEWI4027

This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.

Severity

Low

Description

This EWI is added when a TRY_CONVERT or TRY_CAST cannot be converted to a TRY_CAST in Snowflake.

Snowflake's TRY_CAST function has a limitation as it only allows the conversion of string expressions. However, Transact's TRY_CONVERT and TRY_CAST functions allow any data type expression.

Currently, the transformation from TRY_CONVERT or TRY_CAST to Snowflake's TRY_CAST is only performed for string expressions or expressions that the tool can identify as strings in its context.

Code Example

Input Code:

SELECT TRY_CAST(14.85 AS INT);
SELECT TRY_CONVERT(VARCHAR, 1234);
SELECT TRY_CONVERT(CHAR, 1);
SELECT TRY_CONVERT(SQL_VARIANT, '2017-01-01 12:00:00');
SELECT TRY_CONVERT(GEOGRAPHY, 'LINESTRING(-122.360 47.656, -122.343 47.656 )');

Output Code:

SELECT CAST(14.85 AS INT) /*** MSC-WARNING - MSCEWI4027 - FUNCTION TRY_CAST TRANSFORMED TO CAST ***/;
SELECT TO_VARCHAR( 1234) /*** MSC-WARNING - MSCEWI4027 - FUNCTION TRY_CONVERT TRANSFORMED TO TO_VARCHAR ***/;
SELECT TO_CHAR( 1) /*** MSC-WARNING - MSCEWI4027 - FUNCTION TRY_CONVERT TRANSFORMED TO TO_CHAR ***/;
SELECT TO_VARIANT( '2017-01-01 12:00:00') /*** MSC-WARNING - MSCEWI4027 - FUNCTION TRY_CONVERT TRANSFORMED TO TO_VARIANT ***/;
SELECT TO_GEOGRAPHY( 'LINESTRING(-122.360 47.656, -122.343 47.656 )') /*** MSC-WARNING - MSCEWI4027 - FUNCTION TRY_CONVERT TRANSFORMED TO TO_GEOGRAPHY ***/;

Recommendations

Last updated