Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Splits str by delimiter and return requested part of the split (1-based).
If any input is null, returns null. if partNum is out of range of split parts, returns empty string.
If partNum is 0, throws an error.If partNum is negative,the parts are counted backward from the end of the string.
If the delimiter is an empty string, the str is not split.
For the corresponding Databricks SQL function, see split_part function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.split_part(src=<src>, delimiter=<delimiter>, partNum=<partNum>)
Parameters
| Parameter | Type | Description |
|---|---|---|
src |
pyspark.sql.Column or str |
A column of string to be split. |
delimiter |
pyspark.sql.Column or str |
A column of string, the delimiter used for split. |
partNum |
pyspark.sql.Column or str |
A column of string, requested part of the split (1-based). |
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("11.12.13", ".", 3,)], ["a", "b", "c"])
df.select("*", dbf.split_part("a", "b", "c")).show()
df.select("*", dbf.split_part(df.a, df.b, dbf.lit(-2))).show()