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


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala:
##########
@@ -300,6 +316,44 @@ trait ProvidesHoodieConfig extends Logging {
     }
   }
 
+  def deduceIsOverwriteTable(sparkSession: SparkSession,
+                             catalogTable: HoodieCatalogTable,
+                             partitionSpec: Map[String, Option[String]],
+                             extraOptions: Map[String, String]): Boolean = {
+    val combinedOpts: Map[String, String] = combineOptions(catalogTable, 
catalogTable.tableConfig, sparkSession.sqlContext.conf,
+      defaultOpts = Map.empty, overridingOpts = extraOptions)
+    val operation = combinedOpts.getOrElse(OPERATION.key, null)
+    operation match {
+      case INSERT_OVERWRITE_TABLE_OPERATION_OPT_VAL =>
+        true
+      case INSERT_OVERWRITE_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, 
otherwise respect spark.sql.sources.partitionOverwriteMode
+            val hoodieOverwriteMode = 
sparkSession.sqlContext.getConf(OVERWRITE_MODE.key,

Review Comment:
   should be:
   val hoodieOverwriteMode = combinedOpts.getOrElse(OVERWRITE_MODE.key, 
sparkSession.sqlContext.getConf(PARTITION_OVERWRITE_MODE.key)).toUpperCase()



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