boneanxs commented on code in PR #9113:
URL: https://github.com/apache/hudi/pull/9113#discussion_r1278504522


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala:
##########
@@ -300,6 +316,45 @@ trait ProvidesHoodieConfig extends Logging {
     }
   }
 
+  def deduceIsOverwriteTable(sparkSession: SparkSession,
+                             catalogTable: HoodieCatalogTable,
+                             partitionSpec: Map[String, Option[String]]): 
Boolean = {
+    val operation = sparkSession.sqlContext.getConf(OPERATION.key, "")

Review Comment:
   Better use `combineOptions()` here to keep the sources of HUDI configure 
consistent with others.



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala:
##########
@@ -300,6 +316,45 @@ trait ProvidesHoodieConfig extends Logging {
     }
   }
 
+  def deduceIsOverwriteTable(sparkSession: SparkSession,
+                             catalogTable: HoodieCatalogTable,
+                             partitionSpec: Map[String, Option[String]]): 
Boolean = {
+    val operation = sparkSession.sqlContext.getConf(OPERATION.key, "")
+    if (operation.nonEmpty && 
operation.equals(INSERT_OVERWRITE_TABLE_OPERATION_OPT_VAL)) {
+      true
+    } else if (operation.nonEmpty && 
operation.equals(INSERT_OVERWRITE_OPERATION_OPT_VAL)) {
+      false
+    } else {

Review Comment:
   Use Scala match expression can be more clear?
   ```scala
       operation match {
         case INSERT_OVERWRITE_TABLE_OPERATION_OPT_VAL =>
           true
         case INSERT_OPERATION_OPT_VAL =>
           false
         case _ =>
           // NonPartitioned table always insert overwrite whole table
           if (catalogTable.partitionFields.isEmpty) {
             true
           } else {
             // Insert overwrite partitioned table with PARTITION clause will 
always insert overwrite the specific partition
             if (partitionSpec.nonEmpty) {
               false
             } else {
               // If hoodie.datasource.overwrite.mode configured, respect it
               val hoodieOverwriteMode = 
sparkSession.sqlContext.getConf(OVERWRITE_MODE.key,
                 
sparkSession.sqlContext.getConf(PARTITION_OVERWRITE_MODE.key)).toUpperCase()
               
               hoodieOverwriteMode match {
                 case "STATIC" =>
                   true
                 case "DYNAMIC" =>
                   false
                 case _ =>
                   throw new IllegalArgumentException("xxx")
               }
             }
           }
       }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to