Function Name | Capability Description |
GENERATE_SERIES | GENERATE_SERIES is used to generate a continuous integer series and expand the series into multiple rows. This function is commonly used to construct test data, expand continuous numbering based on start and end values, fill in missing sequences, or expand interval fields into multiple rows. |
JSON_TUPLE | JSON_TUPLE is used to extract multiple fields from a JSON string at once and return them as multiple columns. Compared to repeatedly calling single-field JSON extraction functions, JSON_TUPLE is more suitable for scenarios where multiple fields need to be extracted from the same JSON string. It is commonly used to parse JSON fields in logs, extract event attributes from tracking points, or convert semi-structured JSON content into relational columns. |
MULTI_KEYVALUE | MULTI_KEYVALUE is used to extract the values corresponding to multiple keys from a Key-Value format string at once and return them as multiple columns. It can be considered a multi-field version of KEYVALUE. When multiple keys need to be extracted from the same string, using MULTI_KEYVALUE avoids repeatedly parsing the same field. It is commonly used in scenarios such as parsing extended log fields, parsing URL query parameters, and parsing event attributes from tracking points. |
STRING_SPLIT | STRING_SPLIT is used to split a string by a specified delimiter and expand the resulting substrings into multiple rows. This function is commonly used to split comma-separated tags, expand multi-value fields into multiple rows, or convert a string list into row-level data, facilitating subsequent filtering, joining, or aggregation. |
SELECT valueFROM LATERAL TABLE(GENERATE_SERIES(start, stop)) AS T(value);
Parameter | Type | Required | Description |
start | BIGINT / INT | Yes | The starting value of the sequence, inclusive. |
stop | BIGINT / INT | Yes | The ending value of the sequence, inclusive. |
Returned Column | Type | Description |
User-specified column name | BIGINT | The generated sequence value. The column name is specified by the alias in LATERAL TABLE ... AS T(value). |
SELECT valueFROM LATERAL TABLE(GENERATE_SERIES(1, 5)) AS T(value);
value |
1 |
2 |
3 |
4 |
5 |
SELECT valueFROM LATERAL TABLE(GENERATE_SERIES(start, stop)) AS T(value);
Parameter | Type | Required | Description |
start | BIGINT / INT | Yes | The starting value of the sequence, inclusive. |
stop | BIGINT / INT | Yes | The ending value of the sequence, inclusive. |
Returned Column | Type | Description |
User-specified column name | BIGINT | The generated sequence value. The column name is specified by the alias in LATERAL TABLE ... AS T(value). |
SELECT valueFROM LATERAL TABLE(GENERATE_SERIES(1, 5)) AS T(value);
value |
1 |
2 |
3 |
4 |
5 |
SELECTkv.value1,kv.value2FROM source_table AS s,LATERAL TABLE(MULTI_KEYVALUE(s.ext, '&', '=', 'key1', 'key2')) AS kv(value1, value2);
Parameter | Type | Required | Description |
str | STRING | Yes | The Key-Value string to be parsed. |
split1 | STRING | Yes | The primary delimiter, used to separate multiple Key-Value segments. |
split2 | STRING | Yes | The secondary delimiter, used to separate Key and Value. |
key_name1 | STRING | Yes | The name of the first Key to be extracted. |
key_name2, key_name3, ... | STRING | No | The names of other Keys to be extracted subsequently. |
Returned Column | Type | Description |
User-specified column name | STRING | Each Key corresponds to a returned column. The column name is specified by LATERAL TABLE ... AS alias(...). |
SELECTuid,os,versionFROM LATERAL TABLE(MULTI_KEYVALUE('uid=10001;os=ios;version=1.2.0', ';', '=', 'uid', 'os', 'version')) AS T(uid, os, version);
uid | os | version |
10001 | ios | 1.2.0 |
SELECTt.valueFROM LATERAL TABLE(STRING_SPLIT(str, delimiter)) AS t(value);
Parameter | Type | Required | Description |
str | STRING | Yes | The string to be split. |
delimiter | STRING | Yes | Delimiter. |
Returned Column | Type | Description |
User-specified column name | STRING | The substring after splitting. The column name is specified by LATERAL TABLE ... AS alias(...). |
SELECT valueFROM LATERAL TABLE(STRING_SPLIT('apple,banana,orange', ',')) AS T(value);
value |
apple |
banana |
orange |
SELECT itemFROM LATERAL TABLE(STRING_SPLIT('abc', ',')) AS T(item);
item |
abc |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan