The Search/Analytics feature of Log Service allows you to use string functions to query and analyze logs.

The following table describes the string functions and descriptions.

Function Description
chr(x) Converts the int type to the corresponding ASCII string. Example: chr(65)=A.
codepoint (x) Converts the ASCII type to the corresponding int string. Example: codepoint('A')=65.
length(x) Returns the length of a field.
levenshtein_distance(string1, string2) Returns the minimum edit distance between two strings.
lower(string) Converts the string to lowercase characters.
lpad(string, size, padstring) Aligns string to size. If it is smaller than size, use padstring to fill the size from the left side. If it is larger than size, it is truncated to size.
rpad(string, size, padstring) The same as lpad, complement the string from the right.
ltrim(string) Deletes the white-space characters on the left.
replace(string, search) Deletes search from the string.
replace(string, search,rep) Replaces search with rep in the string.
reverse(string) Returns a string with the reverse order of characters.
rtrim(string) Deletes the space characters at the end of a string.
split(string,delimeter,limit) Splits the string into an array to obtain a maximum of limit values. The generated result is an array with subscripts starting at 1.
split_part(string,delimeter,offset) Splits the string into an array to obtain the offset string. The generated result is a string.
split_to_map(string, entryDelimiter, keyValueDelimiter) → map<varchar, varchar> The string is divided into multiple entries based on entryDelemiter. Each entry is divided into a key and a value based on keyValueDelimiter. The returned result is a map.
position(substring IN string) Query the position in the string where the substring starts.
strpos(string, substring) Finds the starting position of the substring in the string. The returned result starts at 1. If the position is not found, 0 is returned.
substr(string, start) Returns a substring of the string. The substring starts from the position start that ranges from 1.
substr(string, start, length) Returns a substring of the string. The substring starts from position start that ranges from 1. The length of the substring is specified by length.
trim(string) Deletes the space characters at the beginning and end of the string.
upper(string) Converts the string to uppercase characters.
concat(string,string......) Concatenates two or more strings into a single string.
hamming_distance (string1,string2) Returns the Hamming distance between two strings.
Note Strings must be enclosed in single quotation marks. Double quotation marks indicate column names. For example, a=’abc’ indicates column a = string abc, and "a" = “abc” indicates column a = column abc.