pyspark.sql.functions.
octet_length
Calculates the byte length for the specified string column.
New in version 3.3.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
Source column or strings
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)]