diff options
author | ksonj <kson@siberie.de> | 2015-04-29 09:48:47 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-04-29 09:48:47 -0700 |
commit | 3df9c5dd0ce9ce82f9029c2846ad2f6164c501f3 (patch) | |
tree | cbc6998d945841ca868d5cb1a0a5b406f6e6c14b /python/pyspark | |
parent | 687273d9150e1c89a74aa1473f0c6495f56509af (diff) | |
download | spark-3df9c5dd0ce9ce82f9029c2846ad2f6164c501f3.tar.gz spark-3df9c5dd0ce9ce82f9029c2846ad2f6164c501f3.tar.bz2 spark-3df9c5dd0ce9ce82f9029c2846ad2f6164c501f3.zip |
Better error message on access to non-existing attribute
I believe column access via `__getattr__` is bad and shouldn't be implicitly encouraged by the error message when accessing a non-existing attribute on DataFrame. This patch changes the error message from 'no such column' to the more generic 'no such attribute', which is also what Pandas DFs will throw.
Author: ksonj <kson@siberie.de>
Closes #5771 from ksonj/master and squashes the following commits:
bcc2220 [ksonj] Better error message on access to non-existing attribute
Diffstat (limited to 'python/pyspark')
-rw-r--r-- | python/pyspark/sql/dataframe.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/python/pyspark/sql/dataframe.py b/python/pyspark/sql/dataframe.py index 6879fe0805..d9cbbc68b3 100644 --- a/python/pyspark/sql/dataframe.py +++ b/python/pyspark/sql/dataframe.py @@ -633,7 +633,8 @@ class DataFrame(object): [Row(age=2), Row(age=5)] """ if name not in self.columns: - raise AttributeError("No such column: %s" % name) + raise AttributeError( + "'%s' object has no attribute '%s'" % (self.__class__.__name__, name)) jc = self._jdf.apply(name) return Column(jc) |