Skip to content

Commit d800c58

Browse files
committed
Address comments and fix bug.
1 parent 1c145eb commit d800c58

File tree

1 file changed

+21
-18
lines changed
  • sql/core/src/main/scala/org/apache/spark/sql/execution

1 file changed

+21
-18
lines changed

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,42 @@ private[sql] class SparkQl(conf: ParserConf = SimpleParserConf()) extends Cataly
5050
RefreshTable(tableIdent)
5151

5252
case Token("TOK_CREATETABLEUSING", createTableArgs) =>
53-
val clauses = getClauses(
54-
Seq("TEMPORARY", "TOK_IFNOTEXISTS", "TOK_TABNAME", "TOK_TABCOLLIST",
55-
"TOK_TABLEPROVIDER", "TOK_TABLEOPTIONS", "TOK_QUERY"), createTableArgs)
56-
57-
val temp = clauses(0)
58-
val allowExisting = clauses(1)
59-
val Some(tabName) = clauses(2)
60-
val tableCols = clauses(3)
61-
val Some(tableProvider) = clauses(4)
62-
val tableOpts = clauses(5)
63-
val tableAs = clauses(6)
53+
val Seq(
54+
temp,
55+
allowExisting,
56+
Some(tabName),
57+
tableCols,
58+
Some(Token("TOK_TABLEPROVIDER", providerNameParts)),
59+
tableOpts,
60+
tableAs) = getClauses(Seq(
61+
"TEMPORARY",
62+
"TOK_IFNOTEXISTS",
63+
"TOK_TABNAME", "TOK_TABCOLLIST",
64+
"TOK_TABLEPROVIDER",
65+
"TOK_TABLEOPTIONS",
66+
"TOK_QUERY"), createTableArgs)
6467

6568
val tableIdent: TableIdentifier = tabName match {
6669
case Token("TOK_TABNAME", Token(dbName, _) :: Token(tableName, _) :: Nil) =>
67-
new TableIdentifier(tableName, Some(dbName))
70+
new TableIdentifier(cleanIdentifier(tableName), Some(cleanIdentifier(dbName)))
6871
case Token("TOK_TABNAME", Token(tableName, _) :: Nil) =>
69-
TableIdentifier(tableName)
72+
TableIdentifier(cleanIdentifier(tableName))
7073
}
7174

7275
val columns = tableCols.map {
7376
case Token("TOK_TABCOLLIST", fields) => StructType(fields.map(nodeToStructField))
7477
}
7578

76-
val provider = tableProvider match {
77-
case Token("TOK_TABLEPROVIDER", Token(provider, _) :: Nil) => provider
78-
}
79+
val provider = providerNameParts.map {
80+
case Token(name, _) => name
81+
}.mkString(".")
7982

8083
val options = tableOpts.map { opts =>
8184
opts match {
8285
case Token("TOK_TABLEOPTIONS", options) =>
8386
options.map {
8487
case Token("TOK_TABLEOPTION", Token(key, _) :: Token(value, _) :: Nil) =>
85-
(key, value.replaceAll("^\'|^\"|\"$|\'$", ""))
88+
(key, unquoteString(value))
8689
}.asInstanceOf[Seq[(String, String)]].toMap
8790
}
8891
}.getOrElse(Map.empty[String, String])
@@ -148,7 +151,7 @@ private[sql] class SparkQl(conf: ParserConf = SimpleParserConf()) extends Cataly
148151
case tableName :: Nil =>
149152
// It is describing a table with the format like "describe table".
150153
datasources.DescribeCommand(
151-
UnresolvedRelation(TableIdentifier(tableName.text), None),
154+
UnresolvedRelation(TableIdentifier(cleanIdentifier(tableName.text)), None),
152155
isExtended = extended.isDefined)
153156
case _ =>
154157
nodeToDescribeFallback(node)

0 commit comments

Comments
 (0)