snowflake.snowpark.functions.split¶
- snowflake.snowpark.functions.split(str: Union[Column, str], pattern: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L2526-L2577)¶
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" | |] | -------------------------
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" | |] | -----------------------