FROM_BASE64

Byte Function.

Description

Converts the base64-encoded input string_expr into BYTES format.

For more information, please refer to FROM_BASE64 function.

The function FROM_BASE64 is translated to TRY_BASE64_DECODE_BINARY in Snowflake.

Grammar Syntax

FROM_BASE64(string)

Sample Source

BigQuery

SELECT FROM_BASE64('/+A=');

Snowflake

SELECT TRY_BASE64_DECODE_BINARY('/+A=');

Please keep in mind that the default output format for binary data types in BigQuery is 'BASE64' and in Snowflake 'HEX'. You can use the BASE64_ENCODE function or set the BINARY_OUTPUT_FORMAT format if you want to view the data in BASE64 format.

Using FROM_BASE64 function to insert binary data

These functions are not allowed in the values clause in Snowflake. For this reason, the values clause is transformed into a subquery.

CREATE OR REPLACE TABLE bytesTable
(
  COL1 BYTES,
  COL2 BYTES(20)
);

INSERT INTO bytesTable
VALUES (FROM_BASE64('/+A='), FROM_BASE64('/+B='));

Last updated