GitHub user dongjoon-hyun opened a pull request:
https://github.com/apache/spark/pull/12099
[SPARK-14251][SQL] Add SQL command for printing out generated code for
debugging
## What changes were proposed in this pull request?
This PR implements `EXPLAIN CODEGEN` SQL command. In short, this command do
the `explain` and `debugCodegen` at one command. For example,
* (1) `sql("explain extended select 'a' as a group by
1").collect().foreach(println)`
* (2) `sql("select 'a' as a group by 1").debugCodegen()`
* (1+2: This PR) `sql("explain extended codegen select 'a' as a group by
1").collect().foreach(println)`
**Before**
```
scala> import org.apache.spark.sql.execution.debug._
scala> sql("explain extended select 'a' as a group by
1").collect().foreach(println)
[== Parsed Logical Plan ==]
...
[== Analyzed Logical Plan ==]
...
[== Optimized Logical Plan ==]
...
[== Physical Plan ==]
...
scala> sql("select 'a' as a group by 1").debugCodegen()
Found 2 WholeStageCodegen subtrees.
== Subtree 1 / 2 ==
...
Generated code:
...
== Subtree 2 / 2 ==
...
Generated code:
...
```
**After**
```
scala> sql("explain extended codegen select 'a' as a group by
1").collect().foreach(println)
[== Parsed Logical Plan ==]
...
[== Analyzed Logical Plan ==]
...
[== Optimized Logical Plan ==]
...
[== Physical Plan ==]
...
[]
[Found 2 WholeStageCodegen subtrees.]
[== Subtree 1 / 2 ==]
...
[]
[Generated code:]
...
[]
[== Subtree 2 / 2 ==]
...
[]
[Generated code:]
...
```
## How was this patch tested?
Pass the Jenkins tests (including new testcases)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dongjoon-hyun/spark SPARK-14251
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12099.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #12099
----
commit 4e750e5cfecc8b1ac70c788c5811bc947d8acccb
Author: Dongjoon Hyun <[email protected]>
Date: 2016-03-31T18:33:30Z
[SPARK-14251][SQL] Add SQL command for printing out generated code for
debugging
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]