dongjoon-hyun commented on a change in pull request #24385: [SPARK-27480][SQL] 
Improve `EXPLAIN DESC QUERY` to show the input SQL statement
URL: https://github.com/apache/spark/pull/24385#discussion_r277030728
 
 

 ##########
 File path: sql/core/src/test/resources/sql-tests/results/describe-query.sql.out
 ##########
 @@ -154,16 +154,46 @@ DESCRIBE
 
 
 -- !query 15
-DROP TABLE desc_temp1
+EXPLAIN DESC QUERY SELECT * FROM desc_temp2 WHERE key > 0
 -- !query 15 schema
-struct<>
+struct<plan:string>
 -- !query 15 output
-
+== Physical Plan ==
+Execute DescribeQueryCommand
+   +- DescribeQueryCommand SELECT * FROM desc_temp2 WHERE key > 0
 
 
 -- !query 16
-DROP TABLE desc_temp2
+EXPLAIN EXTENDED DESC WITH s AS (SELECT 'hello' as col1) SELECT * FROM s
 -- !query 16 schema
-struct<>
+struct<plan:string>
 -- !query 16 output
+== Parsed Logical Plan ==
+DescribeQueryCommand WITH s AS (SELECT 'hello' as col1) SELECT * FROM s
+
+== Analyzed Logical Plan ==
+col_name: string, data_type: string, comment: string
+DescribeQueryCommand WITH s AS (SELECT 'hello' as col1) SELECT * FROM s
+
+== Optimized Logical Plan ==
+DescribeQueryCommand WITH s AS (SELECT 'hello' as col1) SELECT * FROM s
+
+== Physical Plan ==
+Execute DescribeQueryCommand
+   +- DescribeQueryCommand WITH s AS (SELECT 'hello' as col1) SELECT * FROM s
 
 Review comment:
   One minor concern about this is that the raw SQL string approach might look 
confusing in case of the multi-line queries. For example, I can make the 
following. The surrounding comments and whitespaces are removed, but the 
comment and newlines in the statement survive as expected.
   
   ```scala
   scala> sql("EXPLAIN EXTENDED DESC /* this is gone */ SELECT 1\n /* this 
survives */ \nFROM /* last */\n VALUES(1) /* this is removed, too 
*/").show(false)
   
   |== Parsed Logical Plan ==
   DescribeQueryCommand SELECT 1
    /* this survives */
   FROM /* last */
    VALUES(1)
   
   == Analyzed Logical Plan ==
   col_name: string, data_type: string, comment: string
   DescribeQueryCommand SELECT 1
    /* this survives */
   FROM /* last */
    VALUES(1)
   
   == Optimized Logical Plan ==
   DescribeQueryCommand SELECT 1
    /* this survives */
   FROM /* last */
    VALUES(1)
   
   == Physical Plan ==
   Execute DescribeQueryCommand
      +- DescribeQueryCommand SELECT 1
    /* this survives */
   FROM /* last */
    VALUES(1)
   |
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to