All Products
Search
Document Center

MaxCompute:UNBASE64

Last Updated:Jul 20, 2023

Converts a Base64-encoded string specified by str into a binary value.

Syntax

binary unbase64(string <str>)

Parameters

str: required. A value of the STRING type. It is a Base64-encoded string that you want to convert.

Return value

A value of the BINARY type is returned. If the input parameter is set to null, null is returned.

Examples

  • Example 1: Convert the string YWxpYmFiYQ== into a binary value. Sample statement:
    -- The return value is alibaba. 
    select unbase64('YWxpYmFiYQ==');
    Note If you want a value of the STRING type to be returned, you can use the CAST function to forcefully convert the data type into STRING. Sample statement:
    select cast(unbase64('YWxpYmFiYQ==') as string);
    For more information about how to use the CAST function, see CAST.
  • Example 2: The input parameter is set to null. Sample statement:
    -- The return value is null. 
    select unbase64(null);

Related functions

For more information, see Other functions.