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

    https://github.com/apache/spark/pull/10723#discussion_r50661745
  
    --- 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, _) :: Token(tableName, 
_) :: Nil) =>
    +            new TableIdentifier(cleanIdentifier(tableName), 
Some(cleanIdentifier(dbName)))
    +          case Token("TOK_TABNAME", Token(tableName, _) :: Nil) =>
    +            TableIdentifier(cleanIdentifier(tableName))
    +        }
    +
    +        val columns = tableCols.map {
    +          case Token("TOK_TABCOLLIST", fields) => 
StructType(fields.map(nodeToStructField))
    +        }
    +
    +        val provider = providerNameParts.map {
    +          case Token(name, _) => name
    +        }.mkString(".")
    +
    +        val options = tableOpts.map { opts =>
    +          opts match {
    +            case Token("TOK_TABLEOPTIONS", options) =>
    +              options.map {
    +                case Token("TOK_TABLEOPTION", keysAndValue) =>
    +                  val key = keysAndValue.init.map {
    +                    case Token(k, _) => k
    +                  }.mkString(".")
    +                  val value = unquoteString(keysAndValue.last.text)
    +                  (key, unquoteString(value))
    +              }.asInstanceOf[Seq[(String, String)]].toMap
    +          }
    +        }.getOrElse(Map.empty[String, String])
    +
    +        val asClause = tableAs.map(nodeToPlan(_))
    +
    +        if (temp.isDefined && allowExisting.isDefined) {
    +          throw new DDLException(
    --- End diff --
    
    Actually here the thrown exception will be caught in `CatalystQl` which 
will then throw an `AnalysisException`.  But I agreed that we can remove 
`DDLException`. Only `DDLParser` uses it.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to