Skip to content

Commit

Permalink
[SPARK-5926] [SQL] make DataFrame.explain leverage queryExecution.log…
Browse files Browse the repository at this point in the history
…ical

DataFrame.explain return wrong result when the query is DDL command.

For example, the following two queries should print out the same execution plan, but it not.
sql("create table tb as select * from src where key > 490").explain(true)
sql("explain extended create table tb as select * from src where key > 490")

This is because DataFrame.explain leverage logicalPlan which had been forced executed, we should use  the unexecuted plan queryExecution.logical.

Author: Yanbo Liang <ybliang8@gmail.com>

Closes apache#4707 from yanboliang/spark-5926 and squashes the following commits:

fa6db63 [Yanbo Liang] logicalPlan is not lazy
0e40a1b [Yanbo Liang] make DataFrame.explain leverage queryExecution.logical
  • Loading branch information
yanboliang authored and marmbrus committed Feb 25, 2015
1 parent 12dbf98 commit 41e2e5a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class DataFrame protected[sql](
*/
def explain(extended: Boolean): Unit = {
ExplainCommand(
logicalPlan,
queryExecution.logical,
extended = extended).queryExecution.executedPlan.executeCollect().map {
r => println(r.getString(0))
}
Expand Down

0 comments on commit 41e2e5a

Please sign in to comment.