This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 3240e52 [SPARK-27531][SQL] Improve `EXPLAIN DESC TABLE` to show the input parameters of the command. 3240e52 is described below commit 3240e52dc792fe434c2d29ee2eefc63fba631dd8 Author: Dilip Biswal <dbis...@us.ibm.com> AuthorDate: Mon Apr 22 13:02:10 2019 -0700 [SPARK-27531][SQL] Improve `EXPLAIN DESC TABLE` to show the input parameters of the command. ## What changes were proposed in this pull request? Currently "EXPLAIN DESC TABLE" is special cased and outputs a single row relation as following. Current output: ```sql spark-sql> EXPLAIN DESCRIBE TABLE t; == Physical Plan == *(1) Scan OneRowRelation[] ``` This is not consistent with how we handle explain processing for other commands. In this PR, the inconsistency is handled by removing the special handling for "describe table". After change: ```sql spark-sql> EXPLAIN DESC EXTENDED t == Physical Plan == Execute DescribeTableCommand +- DescribeTableCommand `t`, true ``` ## How was this patch tested? Added new tests in SQLQueryTestSuite. Closes #24427 from dilipbiswal/describe_table_explain2. Authored-by: Dilip Biswal <dbis...@us.ibm.com> Signed-off-by: Dongjoon Hyun <dh...@apple.com> --- .../spark/sql/execution/SparkSqlParser.scala | 12 +--- .../test/resources/sql-tests/inputs/describe.sql | 7 ++ .../resources/sql-tests/results/describe.sql.out | 82 +++++++++++++++++++--- 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala index bfb50be..96af8b3 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala @@ -318,26 +318,16 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder(conf) { val statement = plan(ctx.statement) if (statement == null) { null // This is enough since ParseException will raise later. - } else if (isExplainableStatement(statement)) { + } else { ExplainCommand( logicalPlan = statement, extended = ctx.EXTENDED != null, codegen = ctx.CODEGEN != null, cost = ctx.COST != null) - } else { - ExplainCommand(OneRowRelation()) } } /** - * Determine if a plan should be explained at all. - */ - protected def isExplainableStatement(plan: LogicalPlan): Boolean = plan match { - case _: DescribeTableCommand => false - case _ => true - } - - /** * Create a [[DescribeColumnCommand]] or [[DescribeTableCommand]] logical commands. */ override def visitDescribeTable(ctx: DescribeTableContext): LogicalPlan = withOrigin(ctx) { diff --git a/sql/core/src/test/resources/sql-tests/inputs/describe.sql b/sql/core/src/test/resources/sql-tests/inputs/describe.sql index f26d5ef..a0ee932 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/describe.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/describe.sql @@ -80,6 +80,13 @@ DESC EXTENDED v; -- AnalysisException DESC PARTITION is not allowed on a view DESC v PARTITION (c='Us', d=1); +-- Explain Describe Table +EXPLAIN DESC t; +EXPLAIN DESC EXTENDED t; +EXPLAIN EXTENDED DESC t; +EXPLAIN DESCRIBE t b; +EXPLAIN DESCRIBE t PARTITION (c='Us', d=2); + -- DROP TEST TABLES/VIEWS DROP TABLE t; diff --git a/sql/core/src/test/resources/sql-tests/results/describe.sql.out b/sql/core/src/test/resources/sql-tests/results/describe.sql.out index 9c4b70d..46d9ec3 100644 --- a/sql/core/src/test/resources/sql-tests/results/describe.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/describe.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 36 +-- Number of queries: 41 -- !query 0 @@ -514,32 +514,92 @@ DESC PARTITION is not allowed on a view: v; -- !query 32 -DROP TABLE t +EXPLAIN DESC t -- !query 32 schema -struct<> +struct<plan:string> -- !query 32 output - +== Physical Plan == +Execute DescribeTableCommand + +- DescribeTableCommand `t`, false -- !query 33 -DROP VIEW temp_v +EXPLAIN DESC EXTENDED t -- !query 33 schema -struct<> +struct<plan:string> -- !query 33 output - +== Physical Plan == +Execute DescribeTableCommand + +- DescribeTableCommand `t`, true -- !query 34 -DROP VIEW temp_Data_Source_View +EXPLAIN EXTENDED DESC t -- !query 34 schema -struct<> +struct<plan:string> -- !query 34 output +== Parsed Logical Plan == +DescribeTableCommand `t`, false + +== Analyzed Logical Plan == +col_name: string, data_type: string, comment: string +DescribeTableCommand `t`, false +== Optimized Logical Plan == +DescribeTableCommand `t`, false + +== Physical Plan == +Execute DescribeTableCommand + +- DescribeTableCommand `t`, false -- !query 35 -DROP VIEW v +EXPLAIN DESCRIBE t b -- !query 35 schema -struct<> +struct<plan:string> -- !query 35 output +== Physical Plan == +Execute DescribeColumnCommand + +- DescribeColumnCommand `t`, [b], false + + +-- !query 36 +EXPLAIN DESCRIBE t PARTITION (c='Us', d=2) +-- !query 36 schema +struct<plan:string> +-- !query 36 output +== Physical Plan == +Execute DescribeTableCommand + +- DescribeTableCommand `t`, Map(c -> Us, d -> 2), false + + +-- !query 37 +DROP TABLE t +-- !query 37 schema +struct<> +-- !query 37 output + + + +-- !query 38 +DROP VIEW temp_v +-- !query 38 schema +struct<> +-- !query 38 output + + + +-- !query 39 +DROP VIEW temp_Data_Source_View +-- !query 39 schema +struct<> +-- !query 39 output + + + +-- !query 40 +DROP VIEW v +-- !query 40 schema +struct<> +-- !query 40 output --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org