forked from docs/doc-exports
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>
7.8 KiB
7.8 KiB
keyvalue
This function is used to split str by split1, convert each group into a key-value pair by split2, and return the value corresponding to the key.
Syntax
keyvalue(string <str>,[string <split1>,string <split2>,] string <key>)
Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String to be split |
split1, split2 |
No |
STRING |
Strings used as separators to split the source string. If these two separators are not specified in the expression, the default values are ; for split1 and : for split2. If there are multiple occurrences of split2 within a string that has been split by split1, the result is undefined. |
key |
No |
BIGINT |
The corresponding value when the string is split using split1 and split2. |
Return Values
The return value is of the STRING type.
Example Code
The value 2 is returned.
select keyvalue('a:1;b:2', 'b');
The value 2 is returned.
select keyvalue("\;abc:1\;def:2","\;",":","def");
Parent topic: String Functions