Note
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de changer d’annuaire.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de changer d’annuaire.
Fonction
S’applique à :
Databricks SQL
Databricks Runtime 15.4 et versions ultérieures
Retourne la valeur d’entrée si elle correspond à une chaîne UTF-8 valide, ou lève INVALID_UTF8_STRING sinon.
Syntaxe
validate_utf8(strExpr)
Les arguments
-
strExpr: expressionSTRING.
Retours
Un STRING correspondant octet par octet à strExpr au cas où il représente une chaîne UTF-8 valide, lève INVALID_UTF8_STRING sinon.
Pour retourner NULL si l’entrée n’est pas une chaîne UTF-8 valide, utilisez la fonction try_validate_utf8.
Exemples
– Simple example taking a valid string as input.
> SELECT validate_utf8('Spark')
Spark
– Simple example taking a valid collated string as input.
> SELECT validate_utf8('SQL' COLLATE UTF8_LCASE)
SQL
– Simple example taking a valid hexadecimal string as input.
> SELECT validate_utf8(x'61')
a
– Example taking an invalid hexadecimal string as input (illegal UTF-8 byte sequence).
> SELECT validate_utf8(x'80')
[INVALID_UTF8_STRING] Invalid UTF8 byte sequence found in string: \x80.