substr
Returns the substring of str that starts at pos and is of length len, or the slice of byte array that starts at pos and is of length len.
For the corresponding Databricks SQL function, see substr function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.substr(str=<str>, pos=<pos>, len=<len>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| A column of string. |
|
| A column of string, the substring of |
|
| A column of string, the substring of |
Returns
pyspark.sql.Column: substring of given value.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("Spark SQL", 5, 1,)], ["a", "b", "c"])
df.select("*", dbf.substr("a", "b", "c")).show()
df.select("*", dbf.substr(df.a, df.b)).show()