unhex function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Converts hexadecimal expr to BINARY.

Syntax

unhex(expr)

Arguments

  • expr: A STRING expression of hexadecimal characters.

Returns

The result is BINARY.

If the length of expr is odd, the first character is discarded and the result is padded with a null byte. If expr contains non hex characters the result is NULL.

Examples

> SELECT decode(unhex('537061726B2053514C'), 'UTF-8');
 Spark SQL