This topic describes how to use the string function CONCAT_WS in Realtime Compute.

Syntax

VARCHAR CONCAT_WS(VARCHAR separator, VARCHAR var1, VARCHAR var2, ...)

Input parameters

Parameter Data type Description
separator VARCHAR The separator.
var1 VARCHAR N/A
var2 VARCHAR N/A

Description

Concatenates every two parameter values with a separator and returns a new string. The length and type of the new string depend on the input values.

Note If the separator value is null, the separator is regarded as an empty string used to concatenate the parameter values. If any other parameter is null, the parameter is skipped during concatenation.

Example

  • Test data
    sep (VARCHAR) str1 (VARCHAR) str2 (VARCHAR) str1 (VARCHAR)
    | Jack Harry John
    null Jack Harry John
    | null Harry John
    | Jack null null
  • Test statements
    SELECT CONCAT_WS(sep, str1, str2, str3) as var FROM T1;
  • Test results
    var (VARCHAR)
    Jack|Harry|John
    JackHarryJohn
    Harry|John
    Jack