diff options
-rw-r--r-- | python/pyspark/sql/column.py | 3 | ||||
-rw-r--r-- | python/pyspark/sql/tests.py | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/python/pyspark/sql/column.py b/python/pyspark/sql/column.py index 0948f9b27c..56e75e8cae 100644 --- a/python/pyspark/sql/column.py +++ b/python/pyspark/sql/column.py @@ -226,6 +226,9 @@ class Column(object): raise AttributeError(item) return self.getField(item) + def __iter__(self): + raise TypeError("Column is not iterable") + # string methods rlike = _bin_op("rlike") like = _bin_op("like") diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index fc778631d9..eb449e8679 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -1066,6 +1066,15 @@ class SQLTests(ReusedPySparkTestCase): keys = self.df.withColumn("key", self.df.key).select("key").collect() self.assertEqual([r.key for r in keys], list(range(100))) + # regression test for SPARK-10417 + def test_column_iterator(self): + + def foo(): + for x in self.df.key: + break + + self.assertRaises(TypeError, foo) + class HiveContextSQLTests(ReusedPySparkTestCase): |