len function

Returns the character length of string data or number of bytes of binary data.

Applies to: check marked yes Databricks SQL preview check marked yes Databricks Runtime 11.3 and above

Syntax

len(expr)

Arguments

  • expr: A STRING or BINARY expression.

Returns

An INTEGER.

The length of string data includes the trailing spaces. The length of binary data includes trailing binary zeros.

This function is a synonym for character_length function and char_length function.

Examples

> SELECT len('Spark SQL ');
 10
> SELECT len('床前明月光');
 5