dongjoon-hyun commented on a change in pull request #24385: [SPARK-27480][SQL] 
Improve explain output of describe query command to show the actual input query 
as opposed to a truncated logical plan.
URL: https://github.com/apache/spark/pull/24385#discussion_r276423031
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala
 ##########
 @@ -373,7 +374,11 @@ class SparkSqlAstBuilder(conf: SQLConf) extends 
AstBuilder(conf) {
    * Create a [[DescribeQueryCommand]] logical command.
    */
   override def visitDescribeQuery(ctx: DescribeQueryContext): LogicalPlan = 
withOrigin(ctx) {
-    DescribeQueryCommand(visitQuery(ctx.query))
+    val query = ctx.query
+    val startIndex = query.start.getStartIndex
+    val endIndex = query.stop.getStopIndex
+    val interval = new Interval(startIndex, endIndex)
+    DescribeQueryCommand(query.start.getInputStream.getText(interval), 
visitQuery(ctx.query))
 
 Review comment:
   @dilipbiswal . For consistency, could you improve `DescribeTableCommand` at 
least? For example, it will be useful for the following case.
   ```scala
   spark-sql> EXPLAIN DESCRIBE TABLE t1;
   == Physical Plan ==
   *(1) Scan OneRowRelation[]
   
   spark-sql> EXPLAIN DESCRIBE QUERY SELECT 1;
   == Physical Plan ==
   Execute DescribeQueryCommand
      +- DescribeQueryCommand SELECT 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