pyspark.sql.functions.char_length#
- pyspark.sql.functions.char_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.
Added in version 3.5.0.
- Parameters:
- str
Columnor str Input column or strings. A column that evaluates to a string or binary.
- str
Examples
>>> import pyspark.sql.functions as sf >>> spark.range(1).select(sf.char_length(sf.lit("SparkSQL"))).show() +---------------------+ |char_length(SparkSQL)| +---------------------+ | 8| +---------------------+