SPLIT_TO_TABLE
functionsupportedCore SQL functionsThis table function splits a string (based on a specified delimiter) and flattens the results into rows.
Syntax
SPLIT_TO_TABLE(<string>, <delimiter>)
Parameters
| Name | Required | Description |
|---|---|---|
string | required | Text to be split. |
delimiter | required | Text to split the string by. |
Usage notes
- If string is an empty string, the function returns one row with an empty string in the VALUE column.
- If string is NULL, the function returns no rows. As a result, input rows with a NULL value are omitted from the result of a lateral join, even when you specify LEFT JOIN LATERAL. To keep every input row, use SPLIT with FLATTEN and specify OUTER => TRUE: Copy code SELECT t.id, f.value::VARCHAR AS value FROM my_table t, LATERAL FLATTEN(INPUT => SPLIT(t.s, ' '), OUTER => TRUE) f;
Output
This function returns the following columns: Column name | Data type | Description SEQ | NUMBER | A unique sequence number associated with the input record. The sequence is not guaranteed to be gap-free or ordered. in any particular way. INDEX | NUMBER | The one-based index of the element. VALUE | VARCHAR | The value of the element of the flattened array. Note The query can also access the columns of the original (correlated) table that served as the source of data for this function. If a single row from the original table resulted in multiple rows in the flattened view, the values in this input row are replicated to match the number of rows produced by this function.