wangyum commented on a change in pull request #32852:
URL: https://github.com/apache/spark/pull/32852#discussion_r648972181



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -193,13 +193,34 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with 
SQLConfHelper with Logg
    * This is only used for Common Table Expressions.
    */
   override def visitNamedQuery(ctx: NamedQueryContext): SubqueryAlias = 
withOrigin(ctx) {
-    val subQuery: LogicalPlan = plan(ctx.query).optionalMap(ctx.columnAliases)(
+    val query = if (ctx.query != null) {
+      ctx.query
+    } else {
+      ctx.informationQuery
+    }
+    val subQuery: LogicalPlan = plan(query).optionalMap(ctx.columnAliases)(
       (columnAliases, plan) =>
         UnresolvedSubqueryColumnAliases(visitIdentifierList(columnAliases), 
plan)
     )
     SubqueryAlias(ctx.name.getText, subQuery)
   }
 
+  /**
+   * This feature is used fo information query.
+   */
+  override def visitInfoQuery(ctx: InfoQueryContext): LogicalPlan = 
withOrigin(ctx) {
+    ctx.informationQuery match {
+      case namespaces: ShowNamespacesContext => visitShowNamespaces(namespaces)
+      case tables: ShowTablesContext => visitShowTables(tables)
+      case tableExtended: ShowTableExtendedContext => 
visitShowTableExtended(tableExtended)
+      case tblProperties: ShowTblPropertiesContext => 
visitShowTblProperties(tblProperties)
+      case columns: ShowColumnsContext => visitShowColumns(columns)
+      case views: ShowViewsContext => visitShowViews(views)
+      case partitions: ShowPartitionsContext => visitShowPartitions(partitions)
+      case functions: ShowFunctionsContext => visitShowFunctions(functions)

Review comment:
       Could we throw unsupported exception instead of `MatchError`?




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



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

Reply via email to