aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql/tests.py
diff options
context:
space:
mode:
authorDavies Liu <davies@databricks.com>2015-08-08 08:38:18 -0700
committerDavies Liu <davies.liu@gmail.com>2015-08-08 08:38:18 -0700
commitac507a03c3371cd5404ca195ee0ba0306badfc23 (patch)
treee5dacb90890d3346018059a5be0d5f0b43afae96 /python/pyspark/sql/tests.py
parent74a6541aa82bcd7a052b2e57b5ca55b7c316495b (diff)
downloadspark-ac507a03c3371cd5404ca195ee0ba0306badfc23.tar.gz
spark-ac507a03c3371cd5404ca195ee0ba0306badfc23.tar.bz2
spark-ac507a03c3371cd5404ca195ee0ba0306badfc23.zip
[SPARK-6902] [SQL] [PYSPARK] Row should be read-only
Raise an read-only exception when user try to mutable a Row. Author: Davies Liu <davies@databricks.com> Closes #8009 from davies/readonly_row and squashes the following commits: 8722f3f [Davies Liu] add tests 05a3d36 [Davies Liu] Row should be read-only
Diffstat (limited to 'python/pyspark/sql/tests.py')
-rw-r--r--python/pyspark/sql/tests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py
index 1e3444dd9e..38c83c427a 100644
--- a/python/pyspark/sql/tests.py
+++ b/python/pyspark/sql/tests.py
@@ -179,6 +179,21 @@ class SQLTests(ReusedPySparkTestCase):
ReusedPySparkTestCase.tearDownClass()
shutil.rmtree(cls.tempdir.name, ignore_errors=True)
+ def test_row_should_be_read_only(self):
+ row = Row(a=1, b=2)
+ self.assertEqual(1, row.a)
+
+ def foo():
+ row.a = 3
+ self.assertRaises(Exception, foo)
+
+ row2 = self.sqlCtx.range(10).first()
+ self.assertEqual(0, row2.id)
+
+ def foo2():
+ row2.id = 2
+ self.assertRaises(Exception, foo2)
+
def test_range(self):
self.assertEqual(self.sqlCtx.range(1, 1).count(), 0)
self.assertEqual(self.sqlCtx.range(1, 0, -1).count(), 1)