From b482bef30af04a2c4c761c3601a568d791c81c04 Mon Sep 17 00:00:00 2001 From: Yohel Alvarez Gomez Date: Thu, 29 Feb 2024 07:19:53 -0600 Subject: [PATCH] Adding examples for the split function --- .../com/snowflake/snowpark/functions.scala | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/scala/com/snowflake/snowpark/functions.scala b/src/main/scala/com/snowflake/snowpark/functions.scala index 86ad1969..8361b78d 100644 --- a/src/main/scala/com/snowflake/snowpark/functions.scala +++ b/src/main/scala/com/snowflake/snowpark/functions.scala @@ -1017,6 +1017,46 @@ object functions { /** * 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: + * {{{ + * val df = session.createDataFrame( + * Seq(("many-many-words", "-"), ("hello--hello", "--"))).toDF("V", "D") + * df.select(split(col("V"), col("D"))).show() + * }}} + * ------------------------- + * |"SPLIT(""V"", ""D"")" | + * ------------------------- + * |[ | + * | "many", | + * | "many", | + * | "words" | + * |] | + * |[ | + * | "hello", | + * | "hello" | + * |] | + * ------------------------- + * + * Example 2: + * {{{ + * val df = session.createDataFrame(Seq("many-many-words", "hello-hi-hello")).toDF("V") + * df.select(split(col("V"), lit("-"))).show() + * }}} + * ------------------------- + * |"SPLIT(""V"", ""D"")" | + * ------------------------- + * |[ | + * | "many", | + * | "many", | + * | "words" | + * |] | + * |[ | + * | "hello", | + * | "hello" | + * |] | + * ------------------------- * * @group str_func * @since 0.1.0