pyspark.sql.functions.is_valid_utf8#

pyspark.sql.functions.is_valid_utf8(str)[source]#

Returns true if the input is a valid UTF-8 string, otherwise returns false.

New in version 4.0.0.

Parameters
strColumn or column name

A column of strings, each representing a UTF-8 byte sequence.

Returns
Column

whether the input string is a valid UTF-8 string.

Examples

>>> import pyspark.sql.functions as sf
>>> spark.range(1).select(sf.is_valid_utf8(sf.lit("SparkSQL"))).show()
+-----------------------+
|is_valid_utf8(SparkSQL)|
+-----------------------+
|                   true|
+-----------------------+