snowflake.snowpark.functions.concat_ws

snowflake.snowpark.functions.concat_ws(*cols: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L2872-L2897)

Concatenates two or more strings, or concatenates two or more binary values. If any of the values is null, the result is also null. The CONCAT_WS operator requires at least two arguments, and uses the first argument to separate all following arguments.

Examples::
>>> from snowflake.snowpark.functions import lit
>>> df = session.create_dataframe([['Hello', 'World']], schema=['a', 'b'])
>>> df.select(concat_ws(lit(','), df.a, df.b)).show()
----------------------------------
|"CONCAT_WS(',', ""A"", ""B"")"  |
----------------------------------
|Hello,World                     |
----------------------------------
Copy
>>> df = session.create_dataframe([['Hello', 'World', ',']], schema=['a', 'b', 'sep'])
>>> df.select(concat_ws('sep', df.a, df.b)).show()
--------------------------------------
|"CONCAT_WS(""SEP"", ""A"", ""B"")"  |
--------------------------------------
|Hello,World                         |
--------------------------------------
Copy
语言: 中文