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

    https://github.com/apache/spark/pull/3431#discussion_r21940281
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/sources/ddl.scala ---
    @@ -67,16 +75,35 @@ private[sql] class DDLParser extends 
StandardTokenParsers with PackratParsers wi
       protected lazy val ddl: Parser[LogicalPlan] = createTable
     
       /**
    -   * CREATE TEMPORARY TABLE avroTable
    +   * `CREATE TEMPORARY TABLE avroTable
        * USING org.apache.spark.sql.avro
    -   * OPTIONS (path "../hive/src/test/resources/data/files/episodes.avro")
    +   * OPTIONS (path "../hive/src/test/resources/data/files/episodes.avro")`
    +   * or
    +   * `CREATE TEMPORARY TABLE avroTable(intField int, stringField string...)
    +   * USING org.apache.spark.sql.avro
    +   * OPTIONS (path "../hive/src/test/resources/data/files/episodes.avro")`
        */
       protected lazy val createTable: Parser[LogicalPlan] =
    -    CREATE ~ TEMPORARY ~ TABLE ~> ident ~ (USING ~> className) ~ (OPTIONS 
~> options) ^^ {
    +  (  CREATE ~ TEMPORARY ~ TABLE ~> ident ~ (USING ~> className) ~ (OPTIONS 
~> options) ^^ {
           case tableName ~ provider ~ opts =>
    -        CreateTableUsing(tableName, provider, opts)
    +        CreateTableUsing(tableName, Seq.empty, provider, opts)
    +    }
    +  |
    +    CREATE ~ TEMPORARY ~ TABLE ~> ident
    +      ~ tableCols  ~ (USING ~> className) ~ (OPTIONS ~> options) ^^ {
    +      case tableName ~ tableColumns ~ provider ~ opts =>
    +      CreateTableUsing(tableName, tableColumns, provider, opts)
    +    }
    +  )
    +  protected lazy val tableCol: Parser[(String, String)] =
    --- End diff --
    
    I'd just have this be `Parser[StructField]` since you have all the info you 
need here to construct the final data structure.  This will also make handling 
nested type easier.  Look at `HiveMetastoreTypes` for an example.


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