String Functions

The common string functions of DLI are as follows:

Table 1 String operators

Operator

Returned Data Type

Description

||

VARCHAR

Concatenates two strings.

CHAR_LENGTH

INT

Returns the number of characters in a string.

CHARACTER_LENGTH

INT

Returns the number of characters in a string.

CONCAT

VARCHAR

Concatenates two or more string values to form a new string. If the value of any parameter is NULL, skip this parameter.

CONCAT_WS

VARCHAR

Concatenates each parameter value and the separator specified by the first parameter separator to form a new string. The length and type of the new string depend on the input value.

HASH_CODE

INT

Returns the absolute value of HASH_CODE() of a string. In addition to string, int, bigint, float, and double are also supported.

INITCAP

VARCHAR

Returns a string whose first letter is in uppercase and the other letters in lowercase. Words are sequences of alphanumeric characters separated by non-alphanumeric characters.

IS_ALPHA

BOOLEAN

Checks whether a string contains only letters.

IS_DIGITS

BOOLEAN

Checks whether a string contains only digits.

IS_NUMBER

BOOLEAN

Checks whether a string is numeric.

IS_URL

BOOLEAN

Checks whether a string is a valid URL.

JSON_VALUE

VARCHAR

Obtains the value of a specified path in a JSON string.

KEY_VALUE

VARCHAR

Obtains the value of a key in a key-value pair string.

LOWER

VARCHAR

Returns a string of lowercase characters.

LPAD

VARCHAR

Concatenates the pad string to the left of the str string until the length of the new string reaches the specified length len.

MD5

VARCHAR

Returns the MD5 value of a string. If the parameter is an empty string (that is, the parameter is "), an empty string is returned.

OVERLAY

VARCHAR

Replaces the substring of x with y. Replace length+1 characters starting from start_position.

POSITION

INT

Returns the position of the first occurrence of the target string x in the queried string y. If the target string x does not exist in the queried string y, 0 is returned.

REPLACE

VARCHAR

Replaces all str2 in the str1 string with str3.

  • str1: original character.
  • str2: target character.
  • str3: replacement character.

RPAD

VARCHAR

Concatenates the pad string to the right of the str string until the length of the new string reaches the specified length len.

SHA1

STRING

Returns the SHA1 value of the expr string.

SHA256

STRING

Returns the SHA256 value of the expr string.

STRING_TO_ARRAY

ARRAY[STRING]

Separates the value string as string arrays by using the delimiter.

SUBSTRING

VARCHAR

Returns the substring starting from a fixed position of A. The start position starts from 1.

TRIM

STRING

Removes A at the start position, or end position, or both the start and end positions from B. By default, string expressions A at both the start and end positions are removed.

UPPER

VARCHAR

Returns a string converted to uppercase characters.

||

CHAR_LENGTH

CHARACTER_LENGTH

CONCAT

CONCAT_WS

HASH_CODE

INITCAP

IS_ALPHA

IS_DIGITS

IS_NUMBER

IS_URL

JSON_VALUE

KEY_VALUE

LOWER

LPAD

MD5

OVERLAY

POSITION

REPLACE

RPAD

SHA1

SHA256

STRING_TO_ARRAY

SUBSTRING

TRIM

UPPER