pyspark.sql.functions.octet_length#

pyspark.sql.functions.octet_length(col)[source]#

Calculates the byte length for the specified string column.

New in version 3.3.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

Source column or strings

Returns
Column

Byte length of the col

Examples

>>> from pyspark.sql.functions import octet_length
>>> spark.createDataFrame([('cat',), ( '🐈',)], ['cat']) \
...      .select(octet_length('cat')).collect()
    [Row(octet_length(cat)=3), Row(octet_length(cat)=4)]