baiyangtx commented on code in PR #3387:
URL: https://github.com/apache/amoro/pull/3387#discussion_r1923177607


##########
amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/src/main/scala/org/apache/amoro/spark/sql/catalyst/analysis/RewriteMixedFormatCommand.scala:
##########
@@ -82,35 +86,48 @@ case class RewriteMixedFormatCommand(sparkSession: 
SparkSession) extends Rule[Lo
         optionsMap += (WriteMode.WRITE_MODE_KEY -> 
WriteMode.OVERWRITE_DYNAMIC.mode)
         val newTableSpec = tableSpec.copy(properties = propertiesMap)
         c.copy(tableSpec = newTableSpec, writeOptions = optionsMap)
-      case CreateTableLikeCommand(targetTable, sourceTable, _, provider, 
properties, ifNotExists)
-          if isCreateMixedFormatTableLikeCommand(targetTable, provider) =>
-        val (sourceCatalog, sourceIdentifier) = 
buildCatalogAndIdentifier(sparkSession, sourceTable)
-        val (targetCatalog, targetIdentifier) = 
buildCatalogAndIdentifier(sparkSession, targetTable)
-        val table = sourceCatalog.loadTable(sourceIdentifier)
-        var targetProperties = properties
-        targetProperties += ("provider" -> "arctic")
-        table match {
-          case keyedTable: MixedSparkTable =>
-            keyedTable.table() match {
-              case table: KeyedTable =>
-                targetProperties += ("primary.keys" -> String.join(
-                  ",",
-                  table.primaryKeySpec().fieldNames()))
+      case CreateTableLikeCommand(targetTable, sourceTable, _, provider, 
properties, ifNotExists) =>
+        isCreateMixedFormatTableLikeCommand(targetTable, provider) match {
+          case true =>
+            val (sourceCatalog, sourceIdentifier) =
+              buildCatalogAndIdentifier(sparkSession, sourceTable)
+            val (targetCatalog, targetIdentifier) =
+              buildCatalogAndIdentifier(sparkSession, targetTable)
+            val table = sourceCatalog.loadTable(sourceIdentifier)
+            var targetProperties = properties
+            targetProperties += ("provider" -> "mixed_hive")
+            table match {
+              case keyedTable: MixedSparkTable =>
+                keyedTable.table() match {
+                  case table: KeyedTable =>
+                    targetProperties += ("primary.keys" -> String.join(
+                      ",",
+                      table.primaryKeySpec().fieldNames()))
+                  case _ =>
+                }
               case _ =>
             }
+            val tableSpec = TableSpec(
+              properties = targetProperties.toMap,
+              provider = provider,
+              options = Map.empty,
+              location = None,
+              comment = None,
+              serde = None,
+              external = false)
+            val seq: Seq[String] = Seq(
+              
targetTable.database.getOrElse(sparkSession.catalog.currentDatabase),
+              targetTable.identifier)
+            val name = ResolvedDBObjectName(targetCatalog, seq)
+            CreateTable(name, table.schema(), table.partitioning(), tableSpec, 
ifNotExists)
           case _ =>
+            provider.isDefined match {
+              case true =>
+                throw new UnsupportedOperationException(
+                  s"format ${provider.get} does not support create table like 
command!!!")
+              case false => plan

Review Comment:
   This implementation may impact the logic of other extensions when multiple 
extensions are used together. 
   
   It is recommended to handle only the scenarios you are concerned with in the 
`case conditions =>`



-- 
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: commits-unsubscr...@amoro.apache.org

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

Reply via email to