Splits a string into key-value pairs using split1 as the pair delimiter and split2 as the key-value delimiter, then returns the value for the specified key.
Limitations
Supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.
Syntax
VARCHAR KEYVALUE(VARCHAR str, VARCHAR split1, VARCHAR split2, VARCHAR key_name)
Parameters
| Parameter | Data type | Description |
str |
VARCHAR | The string to split. |
split1 |
VARCHAR | The delimiter that splits str into key-value pairs. |
split2 |
VARCHAR | The delimiter that splits each key-value pair into a key and a value. |
key_name |
VARCHAR | The key whose value to return. |
Note The function returns
NULL in the following cases:
split1orsplit2isNULL.strorkey_nameisNULL.- No matching key is found.
If multiple key-value pairs share the same key, the value from the first matching pair is returned.
Example
- Test data (table T1)
str (VARCHAR) split1 (VARCHAR) split2 (VARCHAR) key1 (VARCHAR) k1=v1;k2=v2 ; = k2 NULL ; | : k1:v1|k2:v2 NULL = : k1:v1|k2:v2 | = NULL k1:v1|k2:v2 | = : - Test statement
SELECT KEYVALUE(str, split1, split2, key1) AS `result` FROM T1; - Test result
result (VARCHAR) v2 NULL NULL NULL NULL