Notiz
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Iech unzemellen oder Verzeechnesser ze änneren.
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Verzeechnesser ze änneren.
Returns a boolean. The value is True if right is found inside left. Returns NULL if either input expression is NULL. Otherwise, returns False. Both left or right must be of STRING or BINARY type.
For the corresponding Databricks SQL function, see contains function.
Syntax
from pyspark.sql import functions as dbf
dbf.contains(left=<left>, right=<right>)
Parameters
| Parameter | Type | Description |
|---|---|---|
left |
pyspark.sql.Column or str |
The input column or strings to check, may be NULL. |
right |
pyspark.sql.Column or str |
The input column or strings to find, may be NULL. |
Examples
df = spark.createDataFrame([("Spark SQL", "Spark")], ['a', 'b'])
df.select(contains(df.a, df.b).alias('r')).collect()
[Row(r=True)]
df = spark.createDataFrame([("414243", "4243",)], ["c", "d"])
df = df.select(to_binary("c").alias("c"), to_binary("d").alias("d"))
df.printSchema()
df.select(contains("c", "d"), contains("d", "c")).show()
+--------------+--------------+
|contains(c, d)|contains(d, c)|
+--------------+--------------+
| true| false|
+--------------+--------------+