You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "lokeshj1703 (via GitHub)" <gi...@apache.org> on 2023/01/22 11:02:56 UTC

[GitHub] [hudi] lokeshj1703 commented on a diff in pull request #7668: [HUDI-2681] Some fixes and config validation when auto generation of record keys is enabled

lokeshj1703 commented on code in PR #7668:
URL: https://github.com/apache/hudi/pull/7668#discussion_r1083431651


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieWriterUtils.scala:
##########
@@ -203,6 +207,34 @@ object HoodieWriterUtils {
       diffConfigs.insert(0, "\nConfig conflict(key\tcurrent value\texisting value):\n")
       throw new HoodieException(diffConfigs.toString.trim)
     }
+
+    if (hoodieConfig.getBoolean(KeyGeneratorOptions.AUTO_GENERATE_RECORD_KEYS)) {
+      val autoGenerateRecordKey = KeyGeneratorOptions.AUTO_GENERATE_RECORD_KEYS.key()
+      if (hoodieConfig.getBoolean(HoodieWriteConfig.COMBINE_BEFORE_INSERT)) {
+        throw new HoodieKeyGeneratorException(s"Config $autoGenerateRecordKey can not be used when " +
+          s"${HoodieWriteConfig.COMBINE_BEFORE_INSERT.key()} is enabled")
+      }
+      if (!hoodieConfig.getBoolean(HoodieWriteConfig.MERGE_ALLOW_DUPLICATE_ON_INSERTS_ENABLE)) {
+        throw new HoodieKeyGeneratorException(s"Config ${HoodieWriteConfig.MERGE_ALLOW_DUPLICATE_ON_INSERTS_ENABLE.key()} " +
+          s"should be enabled when $autoGenerateRecordKey is used")
+      }
+      if (hoodieConfig.getString(DataSourceWriteOptions.TABLE_TYPE) == MOR_TABLE_TYPE_OPT_VAL) {
+        throw new HoodieKeyGeneratorException(s"Config ${DataSourceWriteOptions.TABLE_TYPE.key()} should be set to " +
+          s"COW_TABLE_TYPE_OPT_VAL when $autoGenerateRecordKey is used")
+      }
+      if (hoodieConfig.getString(OPERATION) == UPSERT_OPERATION_OPT_VAL) {

Review Comment:
   Should we change condition to succeed only if insert and bulk insert is enabled? Is it possible for some other operation to execute in this function apart from {insert,upsert and bulk insert}



-- 
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-unsubscribe@hudi.apache.org

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