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.
Examples
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([('cat',), ( '🐈',)], ['cat']) >>> df.select('*', sf.octet_length('cat')).show() +---+-----------------+ |cat|octet_length(cat)| +---+-----------------+ |cat| 3| | 🐈| 4| +---+-----------------+