diff options
author | Davies Liu <davies@databricks.com> | 2015-08-08 08:38:18 -0700 |
---|---|---|
committer | Davies Liu <davies.liu@gmail.com> | 2015-08-08 08:38:18 -0700 |
commit | ac507a03c3371cd5404ca195ee0ba0306badfc23 (patch) | |
tree | e5dacb90890d3346018059a5be0d5f0b43afae96 /python/pyspark/sql/types.py | |
parent | 74a6541aa82bcd7a052b2e57b5ca55b7c316495b (diff) | |
download | spark-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/types.py')
-rw-r--r-- | python/pyspark/sql/types.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/python/pyspark/sql/types.py b/python/pyspark/sql/types.py index e2e6f03ae9..c083bf8990 100644 --- a/python/pyspark/sql/types.py +++ b/python/pyspark/sql/types.py @@ -1246,6 +1246,11 @@ class Row(tuple): except ValueError: raise AttributeError(item) + def __setattr__(self, key, value): + if key != '__fields__': + raise Exception("Row is read-only") + self.__dict__[key] = value + def __reduce__(self): """Returns a tuple so Python knows how to pickle Row.""" if hasattr(self, "__fields__"): |