MSCEWI2050
Translate function has different behavior in certain cases
This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
Low
Description
In most cases, OTRANSLATE Teradata function and Snowflake TRANSLATE show the same behavior.
However, the following two cases should be considered:
NULL parameters
When the second parameter of OTRANSLATE function (the string containing the characters to replace) is NULL the function returns the original string. In Snowflake any NULL parameter sent to the function causes the result to be NULL. Example:
Teradata:
Snowflake:
Length of the third parameter greater than the length of the second parameter
When the third parameter (string with the new characters to replace) is longer than the second parameter, OTRANSLATE ignores the extra characters and performs the replacements as expected. In Snowflake this case is forbidden and will generate an error. Example:
Teradata:
Snowflake:
Example code
Input code:
Output code:
Recommendations
Try to include only the necessary amount of characters in the third parameter, they are ignored in Teradata anyway and cause errors in Snowflake.
When passing expressions that evaluate to string to this function try to avoid expressions that can evaluate to NULL, at least in the second parameter.
If you need more support, you can email us at snowconvert-support@snowflake.com
Last updated