Skip to main content

like

Returns true if str matches pattern with escape, null if any arguments are null, false otherwise. The default escape character is the ''.

For the corresponding Databricks SQL function, see like operator.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.like(str=<str>, pattern=<pattern>, escapeChar=<escapeChar>)

Parameters

Parameter

Type

Description

str

pyspark.sql.Column or str

A string.

pattern

pyspark.sql.Column or str

A string pattern where _ matches any one character and % matches zero or more characters.

escapeChar

pyspark.sql.Column (optional)

An escape character. The default escape character is the ''.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("Spark", "_park")], ['a', 'b'])
df.select(dbf.like(df.a, df.b).alias('r')).collect()
Output
[Row(r=True)]