Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/11573#discussion_r55889875
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkQl.scala ---
@@ -64,10 +83,86 @@ private[sql] class SparkQl(conf: ParserConf =
SimpleParserConf()) extends Cataly
val tableIdent = extractTableIdent(nameParts)
RefreshTable(tableIdent)
+ // CREATE DATABASE [IF NOT EXISTS] database_name [COMMENT
database_comment]
+ // [LOCATION path] [WITH DBPROPERTIES (key1=val1, key2=val2, ...)];
+ case Token("TOK_CREATEDATABASE", Token(databaseName, Nil) :: args) =>
+ val Seq(ifNotExists, dbLocation, databaseComment, dbprops) =
getClauses(Seq(
+ "TOK_IFNOTEXISTS",
+ "TOK_DATABASELOCATION",
+ "TOK_DATABASECOMMENT",
+ "TOK_DATABASEPROPERTIES"), args)
+ val location = dbLocation.map {
+ case Token("TOK_DATABASELOCATION", Token(loc, Nil) :: Nil) =>
unquoteString(loc)
+ case _ => parseFailed("Invalid CREATE DATABASE command", node)
+ }
+ val comment = databaseComment.map {
+ case Token("TOK_DATABASECOMMENT", Token(com, Nil) :: Nil) =>
unquoteString(com)
+ case _ => parseFailed("Invalid CREATE DATABASE command", node)
+ }
+ val props = dbprops.toSeq.flatMap {
+ case Token("TOK_DATABASEPROPERTIES", Token("TOK_DBPROPLIST",
propList) :: Nil) =>
+ extractProps(propList, "TOK_TABLEPROPERTY")
--- End diff --
Maybe it will be also good to provide an example format like what we have
for `TOK_CREATEFUNCTION`?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]