FROM_BYTES

Translation specification for transforming the TO_CHAR function into an equivalent function concatenation in Snowflake

Description

The FROM_BYTES function encodes a sequence of bits into a sequence of characters representing its encoding. For more information check FROM_BYTES(Encoding).

Snowflake does not have support for FROM_BYTES function, however, there are some workarounds that can be done for the most common occurrences of this function.

Sample Source Patterns

Teradata

SELECT 
FROM_BYTES('5A1B'XB, 'base10'), --returns '23067'
FROM_BYTES('5A3F'XB, 'ASCII'), --returns 'Z\ESC '
FROM_BYTES('5A1B'XB, 'base16'); -- returns '5A1B'

Snowflake

SELECT 
TO_NUMBER('5A1B', 'XXXX'),
/*** MSC-ERROR - MSCEWI1031 - ISNULL FUNCTION NOT SUPPORTED ***/
FROM_BYTES('5A3F'XB, 'ASCII'),
TO_BINARY('5A1B', 'HEX');

Known Issues

  1. TO_NUMBER format parameter must match with the digits on the input string.

  2. There is no functional equivalent built-in function for FROM_BYTES when encoding to ANSI

  1. MSCEWI1031: FUNCTION NOT SUPPORTED

Last updated