pyspark.sql.functions.octet_length

pyspark.sql.functions.octet_length(col: ColumnOrName) → pyspark.sql.column.Column

Calculates the byte length for the specified string column.

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)]