UNHEX

更新时间:
复制 MD 格式

Converts a hexadecimal string to a BINARY value.

UNHEX is an additional function introduced in MaxCompute V2.0.

Syntax

BINARY UNHEX(STRING <number>)

Parameters

ParameterRequiredTypeDescription
numberYesSTRINGA hexadecimal string to decode.

Return value

Returns a value of the BINARY type.

InputReturn value
A valid hexadecimal stringThe decoded BINARY value
0An error
nullnull

Examples

Decode a hexadecimal string passed as a string literal:

SELECT UNHEX('616263');
UNHEX('616263')
abc

Decode a hexadecimal value passed as a numeric literal:

SELECT UNHEX(616263);
UNHEX(616263)
abc

Pass a null value:

SELECT UNHEX(null);
UNHEX(null)
null

Related functions

UNHEX is a mathematical function. For more information, see Mathematical functions.