pyspark.sql.functions.character_length#
- pyspark.sql.functions.character_length(str)[source]#
Returns the character length of string data or number of bytes of binary data. The length of string data includes the trailing spaces. The length of binary data includes binary zeros.
New in version 3.5.0.
- Parameters
- str
Column
or str Input column or strings.
- str
Examples
>>> import pyspark.sql.functions as sf >>> spark.range(1).select(sf.character_length(sf.lit("SparkSQL"))).show() +--------------------------+ |character_length(SparkSQL)| +--------------------------+ | 8| +--------------------------+