Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17160#discussion_r104278452
  
    --- Diff: python/pyspark/sql/column.py ---
    @@ -180,7 +180,9 @@ def __init__(self, jc):
         __ror__ = _bin_op("or")
     
         # container operators
    -    __contains__ = _bin_op("contains")
    +    def __contains__(self, item):
    +        raise ValueError("Cannot apply 'in' operator against a column: 
please use 'contains' "
    +                         "in a string column or 'array_contains' function 
for an array column.")
    --- End diff --
    
    What I meant here is use
    
    ```python
    >>> df = spark.range(1)
    >>> df.select(df.id.contains(0)).show()
    ```
    ```
    +---------------+
    |contains(id, 0)|
    +---------------+
    |           true|
    +---------------+
    ```
    
    or
    
    ```python
    >>> from pyspark.sql.functions import array_contains
    >>> df = spark.createDataFrame([[[0]]], ["id"])
    >>> df.select(array_contains(df.id, 0)).show()
    ```
    ```
    +---------------------+
    |array_contains(id, 0)|
    +---------------------+
    |                 true|
    +---------------------+
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to