cloud-fan commented on code in PR #36586:
URL: https://github.com/apache/spark/pull/36586#discussion_r877684804


##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -367,24 +377,40 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
       schema: StructType,
       description: String,
       options: Map[String, String]): DataFrame = {
-    val tableIdent = 
sparkSession.sessionState.sqlParser.parseTableIdentifier(tableName)
+    val idents = 
sparkSession.sessionState.sqlParser.parseMultipartIdentifier(tableName)
     val storage = DataSource.buildStorageFormatFromOptions(options)
     val tableType = if (storage.locationUri.isDefined) {
       CatalogTableType.EXTERNAL
     } else {
       CatalogTableType.MANAGED
     }
-    val tableDesc = CatalogTable(
-      identifier = tableIdent,
-      tableType = tableType,
-      storage = storage,
-      schema = schema,
-      provider = Some(source),
-      comment = { if (description.isEmpty) None else Some(description) }
-    )
-    val plan = CreateTable(tableDesc, SaveMode.ErrorIfExists, None)
+    val location = if (storage.locationUri.isDefined) {
+      val locationStr = storage.locationUri.get.toString
+      Some(locationStr)
+    } else {
+      None
+    }
+
+    val tableSpec =
+      TableSpec(
+        properties = Map(),
+        provider = Some(source),
+        options = options,
+        location = location,
+        comment = { if (description.isEmpty) None else Some(description) },
+        serde = None,
+        external = tableType == CatalogTableType.EXTERNAL)
+
+    val plan =
+      CreateTable(
+        name = UnresolvedDBObjectName(idents, isNamespace = true),
+        tableSchema = schema,
+        partitioning = Seq(),
+        tableSpec = tableSpec,
+        ignoreIfExists = false)

Review Comment:
   ```suggestion
       val plan = CreateTable(
         name = UnresolvedDBObjectName(idents, isNamespace = true),
         tableSchema = schema,
         partitioning = Seq(),
         tableSpec = tableSpec,
         ignoreIfExists = false)
   ```



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

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to