[ 
https://issues.apache.org/jira/browse/SPARK-19701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15894159#comment-15894159
 ] 

Hyukjin Kwon commented on SPARK-19701:
--------------------------------------

I was thinking a way to work around (e.g., hijacking..) but it seems we can't.
BTW, the below codes seems throwing a {{TypeError}} if {{__nonzero__}} or 
{{__bool__}} returns other types.

{code}
class Column(object):
    def __contains__(self, item):
        print "I am contains"
        return Column()
    def __nonzero__(self):
        return "a"

>>> 1 in Column()
I am contains
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __nonzero__ should return bool or int, returned str
{code}


> the `in` operator in pyspark is broken
> --------------------------------------
>
>                 Key: SPARK-19701
>                 URL: https://issues.apache.org/jira/browse/SPARK-19701
>             Project: Spark
>          Issue Type: Bug
>          Components: PySpark
>    Affects Versions: 2.2.0
>            Reporter: Wenchen Fan
>
> {code}
> >>> textFile = spark.read.text("/Users/cloud/dev/spark/README.md")
> >>> linesWithSpark = textFile.filter("Spark" in textFile.value)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/Users/cloud/product/spark/python/pyspark/sql/column.py", line 426, 
> in __nonzero__
>     raise ValueError("Cannot convert column into bool: please use '&' for 
> 'and', '|' for 'or', "
> ValueError: Cannot convert column into bool: please use '&' for 'and', '|' 
> for 'or', '~' for 'not' when building DataFrame boolean expressions.
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to