overlay
Overlay the specified portion of src with replace, starting from byte position pos of src and proceeding for len bytes.
For the corresponding Databricks SQL function, see overlay function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.overlay(src=<src>, replace=<replace>, pos=<pos>, len=<len>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| the string that will be replaced |
|
| the substitution string |
|
| the starting position in src |
|
| the number of bytes to replace in src string by 'replace' defaults to -1, which represents the length of the 'replace' string |
Returns
pyspark.sql.Column: string with replaced values.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("SPARK_SQL", "CORE")], ("x", "y"))
df.select("*", dbf.overlay("x", df.y, 7)).show()
df.select("*", dbf.overlay("x", df.y, 7, 0)).show()
df.select("*", dbf.overlay("x", "y", 7, 2)).show()