FROM_BASE64
Byte Function.
Description
Converts the base64-encoded input
string_exprintoBYTESformat.
For more information, please refer to FROM_BASE64 function.
Grammar Syntax
FROM_BASE64(string)Sample Source
BigQuery
SELECT FROM_BASE64('/+A=');/+A=Snowflake
SELECT TRY_BASE64_DECODE_BINARY('/+A=');/+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='));CREATE OR REPLACE TABLE bytesTable
(
COL1 BINARY /*** MSC-WARNING - MSCEWI1036 - BYTES DATA TYPE CONVERTED TO BINARY ***/,
COL2 BINARY(20) /*** MSC-WARNING - MSCEWI1036 - BYTES DATA TYPE CONVERTED TO BINARY ***/
);
INSERT INTO bytesTable
SELECT
TRY_BASE64_DECODE_BINARY('/+A='),
TRY_BASE64_DECODE_BINARY('/+B=');Last updated
Was this helpful?