File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,9 @@ def __init__(self, jc):
180180 __ror__ = _bin_op ("or" )
181181
182182 # container operators
183- __contains__ = _bin_op ("contains" )
183+ def __contains__ (self , item ):
184+ raise ValueError ("Cannot apply 'in' operator against a column: please use 'contains' "
185+ "in a string column or 'array_contains' function for an array column." )
184186
185187 # bitwise operators
186188 bitwiseOR = _bin_op ("bitwiseOR" )
Original file line number Diff line number Diff line change @@ -967,6 +967,9 @@ def test_column_operators(self):
967967 cs .startswith ('a' ), cs .endswith ('a' )
968968 self .assertTrue (all (isinstance (c , Column ) for c in css ))
969969 self .assertTrue (isinstance (ci .cast (LongType ()), Column ))
970+ self .assertRaisesRegexp (ValueError ,
971+ "Cannot apply 'in' operator against a column" ,
972+ lambda : 1 in cs )
970973
971974 def test_column_getitem (self ):
972975 from pyspark .sql .functions import col
You can’t perform that action at this time.
0 commit comments