Skip to content

Commit

Permalink
[SPARK-5871] output explain in Python
Browse files Browse the repository at this point in the history
Author: Davies Liu <davies@databricks.com>

Closes apache#4658 from davies/explain and squashes the following commits:

db87ea2 [Davies Liu] output explain in Python
  • Loading branch information
Davies Liu authored and marmbrus committed Feb 17, 2015
1 parent 445a755 commit 3df85dc
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions python/pyspark/sql/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,25 @@ def explain(self, extended=False):
debugging purpose.
If extended is False, only prints the physical plan.
"""
self._jdf.explain(extended)
>>> df.explain()
PhysicalRDD [age#0,name#1], MapPartitionsRDD[...] at mapPartitions at SQLContext.scala:...
>>> df.explain(True)
== Parsed Logical Plan ==
...
== Analyzed Logical Plan ==
...
== Optimized Logical Plan ==
...
== Physical Plan ==
...
== RDD ==
"""
if extended:
print self._jdf.queryExecution().toString()
else:
print self._jdf.queryExecution().executedPlan().toString()

def isLocal(self):
"""
Expand Down Expand Up @@ -1034,7 +1051,7 @@ def _test():
Row(name='Bob', age=5, height=85)]).toDF()
(failure_count, test_count) = doctest.testmod(
pyspark.sql.dataframe, globs=globs,
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF)
globs['sc'].stop()
if failure_count:
exit(-1)
Expand Down

0 comments on commit 3df85dc

Please sign in to comment.