pyspark.sql.functions.
length
Computes the character length of string data or number of bytes of binary data. The length of character data includes the trailing spaces. The length of binary data includes binary zeros.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
target column to work on.
length of the value.
Examples
>>> spark.createDataFrame([('ABC ',)], ['a']).select(length('a').alias('length')).collect() [Row(length=4)]