Skip to content

Commit

Permalink
Adding examples for the split function
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yalvarezgomez committed Feb 29, 2024
1 parent 15d19c7 commit b482bef
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/main/scala/com/snowflake/snowpark/functions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b482bef

Please sign in to comment.