Note
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang mag-sign in o magpalit ng mga direktoryo.
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang baguhin ang mga direktoryo.
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()