dilipbiswal commented on a change in pull request #23883: [SPARK-26982][SQL] 
Enhance describe framework to describe the output of a query.
URL: https://github.com/apache/spark/pull/23883#discussion_r260099018
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
 ##########
 @@ -518,8 +520,32 @@ case class DescribeTableCommand(
 
   override def run(sparkSession: SparkSession): Seq[Row] = {
     val result = new ArrayBuffer[Row]
-    val catalog = sparkSession.sessionState.catalog
+    if (query.isDefined) {
+      query.get match {
+        case _: InsertIntoTable | _: InsertIntoDir =>
+          throw new AnalysisException("Describe command is not supported for 
insert statements.")
+        case u @ Union(children) if 
children.forall(_.isInstanceOf[InsertIntoTable]) =>
+          throw new AnalysisException("Describe command is not supported for 
insert statements.")
+        case u: UnresolvedRelation =>
+          describeTable(sparkSession, u.tableIdentifier, partitionSpec, 
isExtended, result)
 
 Review comment:
   @maropu this should have been already covered in describe-table tests. 
Basically, 
   a simple`describe table mytable` will go through it. Thats because its 
matched by `queryPrimary` in sqlBase.g4. I will add comments. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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