position
Returns the position of the first occurrence of substr in str after position start. The given start and return value are 1-based.
For the corresponding Databricks SQL function, see position function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.position(substr=<substr>, str=<str>, start=<start>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| A column of string, substring. |
|
| A column of string. |
|
| A column of string, start position. |
Examples
Python
from pyspark.databricks.sql import functions as dbf
spark.createDataFrame(
[("bar", "foobarbar", 5,)], ["a", "b", "c"]
).select(dbf.position("a", "b", "c")).show()
spark.createDataFrame(
[("bar", "foobarbar", 5,)], ["a", "b", "c"]
).select(dbf.position("a", "b")).show()