Skip to content

Commit abe0198

Browse files
cloud-fanYun Ni
authored andcommitted
[SPARK-19706][PYSPARK] add Column.contains in pyspark
## What changes were proposed in this pull request? to be consistent with the scala API, we should also add `contains` to `Column` in pyspark. ## How was this patch tested? updated unit test Author: Wenchen Fan <[email protected]> Closes apache#17036 from cloud-fan/pyspark.
1 parent f2317ce commit abe0198

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

python/pyspark/sql/column.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def __iter__(self):
248248
raise TypeError("Column is not iterable")
249249

250250
# string methods
251+
contains = _bin_op("contains")
251252
rlike = _bin_op("rlike")
252253
like = _bin_op("like")
253254
startswith = _bin_op("startsWith")

python/pyspark/sql/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ def test_column_operators(self):
944944
self.assertTrue(all(isinstance(c, Column) for c in cb))
945945
cbool = (ci & ci), (ci | ci), (~ci)
946946
self.assertTrue(all(isinstance(c, Column) for c in cbool))
947-
css = cs.like('a'), cs.rlike('a'), cs.asc(), cs.desc(), cs.startswith('a'), cs.endswith('a')
947+
css = cs.contains('a'), cs.like('a'), cs.rlike('a'), cs.asc(), cs.desc(),\
948+
cs.startswith('a'), cs.endswith('a')
948949
self.assertTrue(all(isinstance(c, Column) for c in css))
949950
self.assertTrue(isinstance(ci.cast(LongType()), Column))
950951

0 commit comments

Comments
 (0)