endswith
Returns a boolean. The value is True if str ends with suffix. Returns NULL if either input expression is NULL. Otherwise, returns False. Both str or suffix must be of STRING or BINARY type.
For the corresponding Databricks SQL function, see endswith function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.endswith(str=<str>, suffix=<suffix>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| A column of string. |
|
| A column of string, the suffix. |
Examples
Python
df = spark.createDataFrame([("Spark SQL", "Spark",)], ["a", "b"])
df.select(endswith(df.a, df.b).alias('r')).collect()
Output
[Row(r=False)]
Python
df = spark.createDataFrame([("414243", "4243",)], ["e", "f"])
df = df.select(to_binary("e").alias("e"), to_binary("f").alias("f"))
df.printSchema()
df.select(endswith("e", "f"), endswith("f", "e")).show()
Output
root |-- e: binary (nullable = true) |-- f: binary (nullable = true)
+--------------+--------------+
|endswith(e, f)|endswith(f, e)|
+--------------+--------------+
| true| false|
+--------------+--------------+