doc-exports/docs/dli/sqlreference/dli_spark_lengthb.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

5.0 KiB

lengthb

This function is used to return the length of a specified string in bytes.

Similar function: length. The length function is used to return the length of a string and return a value of the BIGINT type.

Syntax

lengthb(string <str>)

Parameters

Table 1 Parameter

Parameter

Mandatory

Type

Description

str

Yes

STRING

Input string

Return Values

The return value is of the STRING type.

  • If the value of str is not of the STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME type, an error is reported.
  • If the value of str is NULL, NULL is returned.

Example Code

The value 5 is returned.

select lengthb('hello');

The value NULL is returned.

select lengthb(null);