is_valid_utf8
function
Applies to: Databricks SQL Databricks Runtime 15.4 and later
Returns true
if the input is a valid UTF-8 string, otherwise returns false
.
Syntax
is_valid_utf8(strExpr)
Arguments
strExpr
: ASTRING
expression.
Returns
A BOOLEAN
, indicating whether the input STRING represents a valid UTF-8 string.
Examples
- Simple example taking a valid string as input.
> SELECT is_valid_utf8('Spark')
true
- Simple example taking a valid collated string as input.
> SELECT is_valid_utf8('SQL' COLLATE UTF8_LCASE)
true
- Simple example taking a valid hexadecimal string as input.
> SELECT is_valid_utf8(x'61')
true
- Example taking an invalid hexadecimal string as input (illegal UTF-8 byte sequence).
> SELECT is_valid_utf8(x'80')
false
- Example taking an invalid hexadecimal string as input (illegal UTF-8 byte sequence).
> SELECT is_valid_utf8(x'61C262')
false