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.

Added in version 4.0.0.

Parameters:
strColumn or column name

A column of strings, each representing a UTF-8 byte sequence. A column that evaluates to a string.

Returns:
Column

whether the input string is a valid UTF-8 string. Returns a column that evaluates to a boolean.

Examples

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