snowflake.snowpark.functions.split¶

snowflake.snowpark.functions.split(str: Union[Column, str], pattern: Union[Column, str]) → Column[source]¶

Splits a given string with a given separator and returns the result in an array of strings. To specify a string separator, use the lit() function.

Example 1:

>>> df = session.create_dataframe(
...     [["many-many-words", "-"], ["hello--hello", "--"]],
...     schema=["V", "D"],
... ).select(split(col("V"), col("D")))
>>> df.show()
-------------------------
|"SPLIT(""V"", ""D"")"  |
-------------------------
|[                      |
|  "many",              |
|  "many",              |
|  "words"              |
|]                      |
|[                      |
|  "hello",             |
|  "hello"              |
|]                      |
-------------------------
Copy

Example 2:

>>> df = session.create_dataframe([["many-many-words"],["hello-hi-hello"]],schema=["V"],)
>>> df.select(split(col("V"), lit("-"))).show()
-----------------------
|"SPLIT(""V"", '-')"  |
-----------------------
|[                    |
|  "many",            |
|  "many",            |
|  "words"            |
|]                    |
|[                    |
|  "hello",           |
|  "hi",              |
|  "hello"            |
|]                    |
-----------------------
Copy