Skip to content

Commit

Permalink
address comments, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Davies Liu committed Jun 23, 2015
1 parent f70c08e commit 07dff84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/pyspark/sql/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ def over(self, window):
return Column(jc)

def __nonzero__(self):
raise ValueError("Can't convert column into bool: please use '&' for 'and', '|' for 'or', "
"when using Column in a boolean expression.")
raise ValueError("Cannot convert column into bool: please use '&' for 'and', '|' for 'or', "
"'~'for 'not', when using Column in a boolean expression.")
__bool__ = __nonzero__

def __repr__(self):
Expand Down
11 changes: 6 additions & 5 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ def test_explode(self):
self.assertEqual(result[0][1], "b")

def test_and_in_expression(self):
self.assertEqual(4, self.df.filter(self.df.key <= 10 & self.df.value <= "2").count())
self.assertRaises(ValueError, lambda: self.df.key <= 10 & self.df.value <= "2")
self.assertEqual(2, self.df.filter(self.df.key <= 3 | self.df.value < "2").count())
self.assertRaises(ValueError,
lambda: self.df.filter(self.df.key <= 3 | self.df.value < "2").count())
self.assertEqual(4, self.df.filter((self.df.key <= 10) & (self.df.value <= "2")).count())
self.assertRaises(ValueError, lambda: (self.df.key <= 10) and (self.df.value <= "2"))
self.assertEqual(14, self.df.filter((self.df.key <= 3) | (self.df.value < "2")).count())
self.assertRaises(ValueError, lambda: self.df.key <= 3 or self.df.value < "2")
self.assertEqual(99, self.df.filter(~(self.df.key == 1)).count())
self.assertRaises(ValueError, lambda: not self.df.key == 1)

def test_udf_with_callable(self):
d = [Row(number=i, squared=i**2) for i in range(10)]
Expand Down

0 comments on commit 07dff84

Please sign in to comment.