Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
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|
+--------------+--------------+