string_split
string_split函数,根据指定的分隔符将目标字符串拆分为子字符串,并返回子字符串列表。
语法说明
string_split(target, separator)
| 
        参数  | 
      
        数据类型  | 
      
        说明  | 
     
|---|---|---|
| 
        target  | 
      
        STRING  | 
      
        待处理的目标字符串。 
         说明: 
         
  | 
     
| 
        separator  | 
      
        VARCHAR  | 
      
        指定的分隔符,当前仅支持单字符分隔。  | 
     
示例
- 准备测试输入数据 
    
表2 测试源表disSource数据和分隔符 target(STRING)
separator (VARCHAR)
test-flink
-
flink
-
one-two-ww-three
-
 - 输入测试SQL语句
    
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);
 - 查看测试结果 
    
表3 disSink结果表数据 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