Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10723#discussion_r51020936
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkQl.scala ---
    @@ -42,6 +45,95 @@ private[sql] class SparkQl(conf: ParserConf = 
SimpleParserConf()) extends Cataly
               getClauses(Seq("TOK_QUERY", "FORMATTED", "EXTENDED"), 
explainArgs)
             ExplainCommand(nodeToPlan(query), extended = extended.isDefined)
     
    +      case Token("TOK_REFRESHTABLE", nameParts :: Nil) =>
    +        val tableIdent = extractTableIdent(nameParts)
    +        RefreshTable(tableIdent)
    +
    +      case Token("TOK_CREATETABLEUSING", createTableArgs) =>
    +        val Seq(
    +          temp,
    +          allowExisting,
    +          Some(tabName),
    +          tableCols,
    +          Some(Token("TOK_TABLEPROVIDER", providerNameParts)),
    +          tableOpts,
    +          tableAs) = getClauses(Seq(
    +          "TEMPORARY",
    +          "TOK_IFNOTEXISTS",
    +          "TOK_TABNAME", "TOK_TABCOLLIST",
    +          "TOK_TABLEPROVIDER",
    +          "TOK_TABLEOPTIONS",
    +          "TOK_QUERY"), createTableArgs)
    +
    +        val tableIdent: TableIdentifier = tabName match {
    +          case Token("TOK_TABNAME", Token(dbName, Nil) :: Token(tableName, 
Nil) :: Nil) =>
    +            new TableIdentifier(cleanIdentifier(tableName), 
Some(cleanIdentifier(dbName)))
    +          case Token("TOK_TABNAME", Token(tableName, Nil) :: Nil) =>
    +            TableIdentifier(cleanIdentifier(tableName))
    +        }
    +
    +        val columns = tableCols.map {
    +          case Token("TOK_TABCOLLIST", fields) => 
StructType(fields.map(nodeToStructField))
    +        }
    +
    +        val provider = providerNameParts.map {
    +          case Token(name, Nil) => name
    +        }.mkString(".")
    +
    +        val options = tableOpts.map { opts =>
    --- End diff --
    
    Nit: You could also turn the option into a sequence, flatMap over it, and 
create the Map as a result:
    
        val options = tableOpts.toSeq.flatMap { opts =>
          val Token("TOK_TABLEOPTIONS", options) = opts
          options.map {
            case Token("TOK_TABLEOPTION", keysAndValue) =>
              val key = keysAndValue.init.map.(_.text).mkString(".")
              val value = unquoteString(keysAndValue.last.text)
              key -> value
          }
        }.toMap
    
    (note: code is not tested)


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

Reply via email to