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, some workarounds can be done for the most common occurrences of this function.

Sample Source Patterns

Teradata

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

Snowflake

OUT -> Teradata_01.sql
SELECT
--returns '23067'
TO_NUMBER('5A1B', 'XXXX'),
--returns 'Z\ESC '
!!!RESOLVE EWI!!! /*** SSC-EWI-0031 - FROM_BYTES FUNCTION NOT SUPPORTED ***/!!!
FROM_BYTES(TO_BINARY('5A3F'), 'ASCII'),
TO_BINARY('5A1B', 'HEX'); -- returns '5A1B'

Some parts in the output code are omitted for clarity reasons.

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. SSC-EWI-0031: FUNCTION NOT SUPPORTED

Last updated