Text Functions
concat
Syntax | concat(S1,S2,S3...) |
---|---|
Parameter Description | String type parameters; the number of parameters is variable, requiring at least 1 parameter |
Return Type | String |
Description | Concatenates multiple parameters into a single text string. For example: concat('abc', 123) returns a string: 'abc123' |
Examples | concat('abc', 123, 'hello') returns: 'abc123hello' concat('abc', 123) returns: 'abc123' |
initcap
Syntax | initcap(S) |
---|---|
Parameter Description | String type parameter |
Return Value Type | String |
Description | Formats the specified string by capitalizing the first letter of each word and converting other letters to lowercase |
Example | initcap('hello world'), returns: 'Hello World' |
Unsupported Data Sources | tidb, mongodb |
length
Syntax | length(S) |
---|---|
Parameter | String type parameter |
Return Type | Number |
Description | Calculates the length of a string |
Example | length('hello'), returns: 5 |
like
Syntax | like(S, LITERAL_PATTERN) |
---|---|
Parameter Description | 1. String type parameter, optional type: STRING; 2. Specified pattern, optional type: STRING |
Return Type | Boolean |
Description | Specifies whether a field contains a specific string |
Example | like('hello world', 'world'), returns: TRUE |
like_all
Syntax | like_all(S,LITERAL_PATTERN_LIST) |
---|---|
Parameter Description | 1. String type parameter, optional type: STRING; 2. Specified pattern list, optional type: list of strings |
Return Type | Boolean |
Description | Specifies that the field contains all items in the specified string list |
Example | like_all('hello world', ['world','ello']), returns: TRUE |
like_any
Syntax | like_any(S, LITERAL_PATTERN_LIST) |
---|---|
Parameter Description | 1. String type parameter, optional type: STRING; 2. Specified pattern list, optional type: string list |
Return Type | Boolean |
Description | Specifies whether the field contains any item from the given string list |
Example | like_any('hello world', ['world','abcd']), returns: TRUE |
like_ci
Syntax | like_ci(S,LITERAL_PATTERN) |
---|---|
Parameter Description | 1. String type parameter, optional type: STRING; 2. Specified pattern, optional type: STRING |
Return Type | Boolean |
Description | Specifies whether the field contains a specific string, case-insensitive |
Example | like_ci('hello world', 'World'), returns: TRUE |
like_ci_all
Syntax | like_ci_all(S,LITERAL_PATTERN_LIST) |
---|---|
Parameter Description | 1. String type parameter, optional type: STRING; 2. Specified pattern list, optional type: string list |
Return Type | Boolean |
Description | Specifies that the field contains all items in the given string list, case-insensitive |
Example | like_ci_all('hello world', ['World','ello']), returns: TRUE |
like_ci_any
Syntax | like_ci_any(S, LITERAL_PATTERN_LIST) |
---|---|
Parameter Description | 1. String type parameter, optional type: STRING; 2. Specified pattern list, optional type: string list |
Return Type | Boolean |
Description | Checks if the specified field contains any item from the given string list, case-insensitive |
Example | like_ci_any('hello world', ['World','abcd']), returns: TRUE |
lower
Syntax | lower(S) |
---|---|
Parameter | String type parameter |
Return Type | String |
Description | Converts all characters of the specified string to lowercase |
Example | lower('HELLO'), returns: 'hello' |
ltrim
Syntax | ltrim(s1, s2) |
---|---|
Parameters | 1. String type parameter; 2. Specifies the string to be removed |
Return Type | String |
Description | Searches for content in the beginning of the s1 string that matches the s2 string. The search stops when the content no longer matches the s2 string, and the matched content is removed. Example: ltrim('abcbabca','ab'), the result is cbabca |
Example | ltrim('abcbabca','ab'), returns: 'cbabca' |
position
Syntax | position(S, PATTERN) |
---|---|
Parameter Description | 1. The string to search; 2. The substring |
Return Type | Number |
Description | Retrieves the position of the first occurrence of the substring in the specified string |
Example | position('hello world', 'world'), returns: 7 |
regexp_extract
Syntax | regexp_extract(s, regexp, index) |
---|---|
Parameter Description | 1. String type parameter; 2. Regular expression, optional type: string; 3. Desired string index, optional type: number |
Return Type | String |
Description | Splits the string s according to the rules of the regular expression regexp and returns the character specified by index . |
Example | regexp_extract('hello123world', '(\d+)', 1), returns: '123' |
Unsupported Data Sources | None (Supported data sources: Athena, Doris, Postgresql, Spark, Hive, Hologres, Impala, Presto) |
regexp_match
Syntax | regexp_match(s, regexp) |
---|---|
Parameters | 1. String type parameter; 2. Regular expression, optional type: string |
Return Type | Boolean |
Description | Determines whether the string s matches the regular expression regexp pattern. Returns TRUE if the match is successful, otherwise returns FALSE. |
Example | regexp_match('hello123', '\d+'), returns: TRUE |
regexp_replace
Syntax | regexp_replace(s, regexp, replacement) |
---|---|
Parameter Description | 1. String type parameter; 2. Regular expression, optional type: string; 3. New string |
Return Type | String type |
Description | Replaces characters in the string s that match the regular expression regexp with the specified string replacement |
Example | regexp_replace('hello123world', '\d+', ''), returns: 'helloworld' |
replace
Syntax | replace(s,s1,s2) |
---|---|
Parameter Description | 1. String type parameter; 2. Original string; 3. New string |
Return Type | String |
Description | Replace a string. Usage: replace(s, s1, s2), s2 replaces all occurrences of s1 in s |
Example | replace('hello world', 'world', 'there'), returns: 'hello there' |
rtrim
Syntax | rtrim(s1, s2) |
---|---|
Parameters | 1. String type parameter; 2. Specifies the string to be removed |
Return Type | String |
Description | Starting from the end of the s1 string, it searches backward for content matching the s2 string. The search stops when the content no longer matches the s2 string, and the matched content is removed. Example: rtrim('abadcdabab','ab') returns abadcd |
Example | rtrim('abadcdabab','ab'), returns: 'abadcd' |
split
Syntax | split(s, delimiter, n) |
---|---|
Parameter Description | 1. String type parameter; 2. Delimiter, optional type: string; 3. Desired string index, optional type: number |
Return Type | String |
Description | Splits the string s by the delimiter delimiter and returns the nth (starting from 1) split string. For example, split('abc,abc,abcdef',',',3) returns the string abcdef . |
Example | split('abc,abc,abcdef',',',3) returns: 'abcdef' |
to_string
Syntax | to_string(ARG) |
---|---|
Parameter | Argument of any type |
Return Type | String |
Description | Converts the input field or value into a string |
Example | to_string(123), returns: '123' |
trim
Syntax | trim(S) |
---|---|
Parameter | String type parameter |
Return Type | String |
Description | Removes leading and trailing spaces from a string |
Example | trim(' hello '), returns: 'hello' |
upper
Syntax | upper(S) |
---|---|
Parameters | String type parameter |
Return Type | String |
Description | Converts all characters of the specified string to uppercase |
Example | upper('hello'), returns: 'HELLO' |
unlike
Syntax | unlike(S, LITERAL_PATTERN) |
---|---|
Parameter Description | 1. String type parameter; 2. Specified pattern, optional type: string |
Return Type | Boolean |
Description | Specifies that the field does not contain a particular string |
Example | unlike('hello world', 'test'), returns: TRUE |
unlike_ci
Syntax | unlike_ci(S,LITERAL_PATTERN) |
---|---|
Parameter Description | 1. String type parameter; 2. Specified pattern, optional type: string |
Return Type | Boolean |
Description | Specifies that the field does not contain a particular string, case-insensitive |
Example | unlike_ci('hello world', 'HE'), returns: FALSE |