Repository: spark Updated Branches: refs/heads/master 09ed6e771 -> 4fa4cf1d4
[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 #17036 from cloud-fan/pyspark. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/4fa4cf1d Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/4fa4cf1d Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/4fa4cf1d Branch: refs/heads/master Commit: 4fa4cf1d4ce51ce61e535cfad57385cb5c23b96d Parents: 09ed6e7 Author: Wenchen Fan <[email protected]> Authored: Thu Feb 23 13:22:39 2017 -0800 Committer: Wenchen Fan <[email protected]> Committed: Thu Feb 23 13:22:39 2017 -0800 ---------------------------------------------------------------------- python/pyspark/sql/column.py | 1 + python/pyspark/sql/tests.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/4fa4cf1d/python/pyspark/sql/column.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/column.py b/python/pyspark/sql/column.py index 0df187a..c10ab96 100644 --- a/python/pyspark/sql/column.py +++ b/python/pyspark/sql/column.py @@ -248,6 +248,7 @@ class Column(object): raise TypeError("Column is not iterable") # string methods + contains = _bin_op("contains") rlike = _bin_op("rlike") like = _bin_op("like") startswith = _bin_op("startsWith") http://git-wip-us.apache.org/repos/asf/spark/blob/4fa4cf1d/python/pyspark/sql/tests.py ---------------------------------------------------------------------- diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index 9058443..abd68bf 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -944,7 +944,8 @@ class SQLTests(ReusedPySparkTestCase): self.assertTrue(all(isinstance(c, Column) for c in cb)) cbool = (ci & ci), (ci | ci), (~ci) self.assertTrue(all(isinstance(c, Column) for c in cbool)) - css = cs.like('a'), cs.rlike('a'), cs.asc(), cs.desc(), cs.startswith('a'), cs.endswith('a') + css = cs.contains('a'), cs.like('a'), cs.rlike('a'), cs.asc(), cs.desc(),\ + cs.startswith('a'), cs.endswith('a') self.assertTrue(all(isinstance(c, Column) for c in css)) self.assertTrue(isinstance(ci.cast(LongType()), Column)) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
