cloud-fan commented on a change in pull request #26921: [SPARK-30282][SQL] 
Integrate V2 commands with UnresolvedV2Relation into new resolution framework
URL: https://github.com/apache/spark/pull/26921#discussion_r364569092
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 ##########
 @@ -201,22 +201,21 @@ class ResolveSessionCatalog(
     case RenameTableStatement(SessionCatalogAndTable(_, oldName), 
newNameParts, isView) =>
       AlterTableRenameCommand(oldName.asTableIdentifier, 
newNameParts.asTableIdentifier, isView)
 
-    case DescribeTableStatement(
-         nameParts @ SessionCatalogAndTable(catalog, tbl), partitionSpec, 
isExtended) =>
-      loadTable(catalog, tbl.asIdentifier).collect {
-        case v1Table: V1Table =>
-          DescribeTableCommand(tbl.asTableIdentifier, partitionSpec, 
isExtended)
-      }.getOrElse {
-        // The v1 `DescribeTableCommand` can describe view as well.
-        if (isView(tbl)) {
-          DescribeTableCommand(tbl.asTableIdentifier, partitionSpec, 
isExtended)
-        } else {
-          if (partitionSpec.nonEmpty) {
-            throw new AnalysisException("DESCRIBE TABLE does not support 
partition for v2 tables.")
+    case d @ DescribeTable(SessionCatalogAndResolvedTable(resolved), 
partitionSpec, isExtended) =>
+      resolved.table match {
+        case _: V1Table =>
+          DescribeTableCommand(getTableIdentifier(resolved), partitionSpec, 
isExtended)
+        case _ =>
+          // The v1 `DescribeTableCommand` can describe view as well.
+          if (isView(resolved.identifier.asMultipartIdentifier)) {
 
 Review comment:
   Actually, I checked with hive: 
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DescribeTable/View/MaterializedView/Column
   
   The DESCRIBE command works for both table and view, in Spark we have a weird 
parser rule `DESC TABLE?` which makes people think it's for table only.
   
   We can keep the parser rule, but we should rename `DescribeTable` to 
`DescribeRelation`, and use `UnresolvedRelation` to allow both table and view.

----------------------------------------------------------------
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