cloud-fan commented on a change in pull request #26466: [SPARK-29839][SQL] 
Supporting STORED AS in CREATE TABLE LIKE
URL: https://github.com/apache/spark/pull/26466#discussion_r351125841
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala
 ##########
 @@ -556,15 +556,49 @@ class SparkSqlAstBuilder(conf: SQLConf) extends 
AstBuilder(conf) {
    * For example:
    * {{{
    *   CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
-   *   LIKE [other_db_name.]existing_table_name [USING provider] [locationSpec]
+   *   LIKE [other_db_name.]existing_table_name
+   *   [ROW FORMAT row_format]
+   *   [USING provider | STORED AS hiveFormat]
+   *   [locationSpec] [TBLPROPERTIES (property_name=property_value, ...)]
    * }}}
    */
   override def visitCreateTableLike(ctx: CreateTableLikeContext): LogicalPlan 
= withOrigin(ctx) {
     val targetTable = visitTableIdentifier(ctx.target)
     val sourceTable = visitTableIdentifier(ctx.source)
-    val provider = Option(ctx.tableProvider).map(_.multipartIdentifier.getText)
-    val location = Option(ctx.locationSpec).map(visitLocationSpec)
-    CreateTableLikeCommand(targetTable, sourceTable, provider, location, 
ctx.EXISTS != null)
+    checkDuplicateClauses(ctx.tableProvider, "PROVIDER", ctx)
+    checkDuplicateClauses(ctx.createFileFormat, "STORED AS/BY", ctx)
+    checkDuplicateClauses(ctx.rowFormat, "ROW FORMAT", ctx)
+    checkDuplicateClauses(ctx.locationSpec, "LOCATION", ctx)
+    checkDuplicateClauses(ctx.TBLPROPERTIES, "TBLPROPERTIES", ctx)
+    val provider = 
ctx.tableProvider.asScala.headOption.map(_.multipartIdentifier.getText)
+    val location = ctx.locationSpec.asScala.headOption.map(visitLocationSpec)
+    // rowStorage used to determine CatalogStorageFormat.serde and 
CatalogStorageFormat.properties
+    // for Hive table.
+    val rowStorage = ctx.rowFormat.asScala.headOption.map(visitRowFormat)
+      .getOrElse(CatalogStorageFormat.empty)
+    if (provider.isDefined && provider.get.toLowerCase(Locale.ROOT) != 
DDLUtils.HIVE_PROVIDER &&
 
 Review comment:
   actually, if we write `USING hive`, it's not allowed to write `STORED AS` or 
`ROW FORMAT`. Users need to specify serde propoerties via `OPTIONS`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to