All Products
Search
Document Center

Realtime Compute for Apache Flink:STRING_SPLIT

Last Updated:Aug 31, 2023

This topic describes how to use the STRING_SPLIT function. This function splits a string into substrings based on the specified delimiter and returns a list of substrings.

Limits

This function is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.

Syntax

string_split(string, separator)

Input parameters

Parameter

Data type

Description

string

VARCHAR

The string that you want to split.

separator

VARCHAR

The delimiter.

Note

The delimiter must be a single string.

Note
  • If the value of a string is NULL, an empty row is returned.

  • If the string does not contain the specified delimiter, the whole string that you want to split is returned.

  • Two or more consecutive delimiters are considered one delimiter.

Example

  • Test data

    Table 1 T1

    d(varchar)

    s(varchar)

    abc-bcd

    -

    hhh

    -

    abbbbcd

    b

  • Test statements

    SELECT d,v 
    FROM T1, 
    lateral table(string_split(d, s)) as T(v);
  • Test results

    d(varchar)

    v(varchar)

    abbbbcd

    cd

    abbbbcd

    a

    abc-bcd

    abc

    abc-bcd

    bcd

    hhh

    hhh