char_length function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns the character length of string data or number of bytes of binary data. This function is a synonym for character_length function and length function.

Syntax

char_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.

Examples

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