-
- Downloads
[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 which returns generated codes like `debugCodegen`. In `spark-shell`, we don't need to `import debug` module. In `spark-sql`, we can use this SQL command now. **Before** ``` scala> import org.apache.spark.sql.execution.debug._ 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) [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) Author: Dongjoon Hyun <dongjoon@apache.org> Closes #12099 from dongjoon-hyun/SPARK-14251.
Showing
- sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 3 additions, 2 deletions...in/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
- sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala 2 additions, 1 deletion...scala/org/apache/spark/sql/execution/SparkSqlParser.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala 11 additions, 4 deletions...ala/org/apache/spark/sql/execution/command/commands.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/debug/package.scala 21 additions, 22 deletions.../scala/org/apache/spark/sql/execution/debug/package.scala
- sql/core/src/test/scala/org/apache/spark/sql/execution/debug/DebuggingSuite.scala 1 addition, 1 deletion...org/apache/spark/sql/execution/debug/DebuggingSuite.scala
- sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala 0 additions, 1 deletion.../scala/org/apache/spark/sql/hive/execution/commands.scala
- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala 29 additions, 0 deletions...rg/apache/spark/sql/hive/execution/HiveExplainSuite.scala
Loading
Please register or sign in to comment