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.
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
from pyspark.databricks.sql import functions as dbf
dbf.position(substr=<substr>, str=<str>, start=<start>)
Parameters
| Parameter | Type | Description |
|---|---|---|
substr |
pyspark.sql.Column or str |
A column of string, substring. |
str |
pyspark.sql.Column or str |
A column of string. |
start |
pyspark.sql.Column or str, optional |
A column of string, start position. |
Examples
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()