character_length function (Databricks SQL)

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

Syntax

character_length(expr)

Arguments

  • expr: A BINARY or STRING expression.

Returns

The result type is INTEGER.

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

This function is a synonym for char_length function (Databricks SQL) and length function (Databricks SQL).

Examples

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