CTCC1 opened a new pull request, #46045:
URL: https://github.com/apache/spark/pull/46045
### What changes were proposed in this pull request?
Support column type in `split` function for scala and python. SQL already
supports this, but scala / python functions currently don't.
A hypothetical example to illustrate:
```
import org.apache.spark.sql.functions.{col, split}
val example = spark.createDataFrame(
Seq(
("Doe, John", ", ", 2),
("Smith,Jane", ",", 2),
("Johnson", ",", 1)
)
)
.toDF("name", "delim", "expected_parts_count")
example.createOrReplaceTempView("test_data")
// works for SQL
spark.sql("SELECT split(name, delim, expected_parts_count) AS name_parts
FROM test_data").show()
// currently doesn't compile for scala, but will be supported after this PR
example.withColumn("name_parts", split(col("name"), col("delim"),
col("expected_parts_count"))).show()
```
### Why are the changes needed?
I have a use case to split a String typed column with different delimiters
defined in other columns of the Dataframe.
But also following this guidance:
https://github.com/apache/spark/blob/85c4f053f25a7f20546600e179a7303a4409834f/sql/core/src/main/scala/org/apache/spark/sql/functions.scala#L59-L61
### Does this PR introduce _any_ user-facing change?
Yes, new feature (via function overloading).
### How was this patch tested?
Added unit tests with column input type to scala functions - both core and
connect.
### Was this patch authored or co-authored using generative AI tooling?
No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]