Pyspark dataframe LIKE operator

apache-spark-sql, pyspark

Solution

You can use `where` and `col` functions to do the same. `where` will be used for filtering of data based on a condition (here it is, if a column is like `'%string%'`). The `col('col_name')` is used to represent the condition and `like` is the operator:

df.where(col('col1').like("%string%")).show()

Problem

What is the equivalent in Pyspark for LIKE operator? For example I would like to do: ``` SELECT * FROM table WHERE column LIKE "*somestring*"; ``` looking for something easy like this (but this is not working): ``` df.select('column').where(col('column').like("*s*")).show() ```

Original source

Related problems