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>
13 KiB
13 KiB
string_split
The string_split function splits a target string into substrings based on the specified separator and returns a substring list.
Description
string_split(target, separator)
Parameter |
Type |
Description |
---|---|---|
target |
STRING |
Target string to be processed NOTE:
|
separator |
VARCHAR |
Delimiter. Currently, only single-character delimiters are supported. |
Example
- Prepare test input data.
Table 2 Source table disSource target (STRING)
separator (VARCHAR)
test-flink
-
flink
-
one-two-ww-three
-
- Write test SQL statements.
create table disSource( target STRING, separator VARCHAR ) with ( "connector.type" = "dis", "connector.region" = "xxx", "connector.channel" = "ygj-dis-in", "format.type" = 'csv' ); create table disSink( target STRING, item STRING ) with ( 'connector.type' = 'dis', 'connector.region' = 'xxx', 'connector.channel' = 'ygj-dis-out', 'format.type' = 'csv' ); insert into disSink select target, item from disSource, lateral table(string_split(target, separator)) as T(item);
- Check test results.
Table 3 disSink result table target (STRING)
item (STRING)
test-flink
test
test-flink
flink
flink
flink
one-two-ww-three
one
one-two-ww-three
two
one-two-ww-three
ww
one-two-ww-three
three
Parent topic: Table-Valued Functions