Converts a hexadecimal string to a BINARY value.
UNHEX is an additional function introduced in MaxCompute V2.0.
Syntax
BINARY UNHEX(STRING <number>)Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
number | Yes | STRING | A hexadecimal string to decode. |
Return value
Returns a value of the BINARY type.
| Input | Return value |
|---|---|
| A valid hexadecimal string | The decoded BINARY value |
0 | An error |
null | null |
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.