diff options
author | zero323 <zero323@users.noreply.github.com> | 2017-02-13 15:23:56 -0800 |
---|---|---|
committer | Holden Karau <holden@us.ibm.com> | 2017-02-13 15:23:56 -0800 |
commit | e02ac303c6356cdf7fffec7361311d828a723afe (patch) | |
tree | a9546d0c1f69c2325b23ffbf06c9e7b28ae916fd /python/pyspark/sql/tests.py | |
parent | 0169360ef58891ca10a8d64d1c8637c7b873cbdd (diff) | |
download | spark-e02ac303c6356cdf7fffec7361311d828a723afe.tar.gz spark-e02ac303c6356cdf7fffec7361311d828a723afe.tar.bz2 spark-e02ac303c6356cdf7fffec7361311d828a723afe.zip |
[SPARK-19429][PYTHON][SQL] Support slice arguments in Column.__getitem__
## What changes were proposed in this pull request?
- Add support for `slice` arguments in `Column.__getitem__`.
- Remove obsolete `__getslice__` bindings.
## How was this patch tested?
Existing unit tests, additional tests covering `[]` with `slice`.
Author: zero323 <zero323@users.noreply.github.com>
Closes #16771 from zero323/SPARK-19429.
Diffstat (limited to 'python/pyspark/sql/tests.py')
-rw-r--r-- | python/pyspark/sql/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index ab9d3f6c94..d9d03337ff 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -874,6 +874,14 @@ class SQLTests(ReusedPySparkTestCase): self.assertTrue(all(isinstance(c, Column) for c in css)) self.assertTrue(isinstance(ci.cast(LongType()), Column)) + def test_column_getitem(self): + from pyspark.sql.functions import col + + self.assertIsInstance(col("foo")[1:3], Column) + self.assertIsInstance(col("foo")[0], Column) + self.assertIsInstance(col("foo")["bar"], Column) + self.assertRaises(ValueError, lambda: col("foo")[0:10:2]) + def test_column_select(self): df = self.df self.assertEqual(self.testData, df.select("*").collect()) |