-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-5464] Fix help() for Python DataFrame instances #4278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2136,9 +2136,9 @@ def __getitem__(self, item): | |
|
|
||
| def __getattr__(self, name): | ||
| """ Return the column by given name """ | ||
| if isinstance(name, basestring): | ||
| return Column(self._jdf.apply(name)) | ||
| raise AttributeError | ||
| if name.startswith("__"): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| raise AttributeError(name) | ||
| return Column(self._jdf.apply(name)) | ||
|
|
||
| def alias(self, name): | ||
| """ Alias the current DataFrame """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| from fileinput import input | ||
| from glob import glob | ||
| import os | ||
| import pydoc | ||
| import re | ||
| import shutil | ||
| import subprocess | ||
|
|
@@ -1032,6 +1033,15 @@ def test_aggregator(self): | |
| from pyspark.sql import Aggregator as Agg | ||
| # self.assertEqual((0, '100'), tuple(g.agg(Agg.first(df.key), Agg.last(df.value)).first())) | ||
|
|
||
| def test_help_command(self): | ||
| # Regression test for SPARK-5464 | ||
| rdd = self.sc.parallelize(['{"foo":"bar"}', '{"foo":"baz"}']) | ||
| df = self.sqlCtx.jsonRDD(rdd) | ||
| # render_doc() reproduces the help() exception without printing output | ||
| pydoc.render_doc(df) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the case that threw an exception. The other two cases below are just to improve our test-coverage, since those classes also have custom |
||
| pydoc.render_doc(df.foo) | ||
| pydoc.render_doc(df.take(1)) | ||
|
|
||
|
|
||
| class InputFormatTests(ReusedPySparkTestCase): | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this check because
getattrcan only be called with strings: