Skip to content

Commit f886f67

Browse files
committed
Migrate DDL parsing to the newly absorbed parser: describe command.
1 parent 8cfa218 commit f886f67

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/SparkQl.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,30 @@ private[sql] class SparkQl(conf: ParserConf = SimpleParserConf()) extends Cataly
5252
nodeToDescribeFallback(node)
5353
} else {
5454
tableType match {
55-
case Token("TOK_TABTYPE", Token("TOK_TABNAME", nameParts :: Nil) :: Nil) =>
55+
case Token("TOK_TABTYPE", Token("TOK_TABNAME", nameParts) :: Nil) =>
5656
nameParts match {
57-
case Token(".", dbName :: tableName :: Nil) =>
57+
case Token(dbName, _) :: Token(tableName, _) :: Nil =>
5858
// It is describing a table with the format like "describe db.table".
5959
// TODO: Actually, a user may mean tableName.columnName. Need to resolve this
6060
// issue.
61-
val tableIdent = extractTableIdent(nameParts)
61+
val tableIdent = TableIdentifier(
62+
cleanIdentifier(tableName), Some(cleanIdentifier(dbName)))
6263
datasources.DescribeCommand(
6364
UnresolvedRelation(tableIdent, None), isExtended = extended.isDefined)
64-
case Token(".", dbName :: tableName :: colName :: Nil) =>
65+
case Token(dbName, _) :: Token(tableName, _) :: Token(colName, _) :: Nil =>
6566
// It is describing a column with the format like "describe db.table column".
6667
nodeToDescribeFallback(node)
67-
case tableName =>
68+
case tableName :: Nil =>
6869
// It is describing a table with the format like "describe table".
6970
datasources.DescribeCommand(
7071
UnresolvedRelation(TableIdentifier(tableName.text), None),
7172
isExtended = extended.isDefined)
73+
case _ =>
74+
nodeToDescribeFallback(node)
7275
}
7376
// All other cases.
74-
case _ => nodeToDescribeFallback(node)
77+
case _ =>
78+
nodeToDescribeFallback(node)
7579
}
7680
}
7781

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DDLParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DDLParser(parseQuery: String => LogicalPlan)
6161
protected val COMMENT = Keyword("COMMENT")
6262
protected val REFRESH = Keyword("REFRESH")
6363

64-
protected lazy val ddl: Parser[LogicalPlan] = createTable | describeTable | refreshTable
64+
protected lazy val ddl: Parser[LogicalPlan] = createTable | refreshTable
6565

6666
protected def start: Parser[LogicalPlan] = ddl
6767

0 commit comments

Comments
 (0)