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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/HoodieTableConfig.java:
##########
@@ -801,19 +843,93 @@ public String getPayloadClass() {
     return HoodieRecordPayload.getPayloadClassName(this);
   }
 
+  public String getLegacyPayloadClass() {
+    return getStringOrDefault(LEGACY_PAYLOAD_CLASS_NAME, "");
+  }
+
   public String getRecordMergeStrategyId() {
     return getString(RECORD_MERGE_STRATEGY_ID);
   }
 
+  /**
+   * Handle table config creation logic when creating a table for Table 
Version 9,
+   * which is based on the logic of table version < 9, and then tuned for 
version 9 logic.
+   * This approach fits the same behavior of upgrade from 8 to 9.
+   */
+  public static Map<String, String> 
inferMergingConfigsForVersion9(RecordMergeMode recordMergeMode,
+                                                                   String 
payloadClassName,
+                                                                   String 
recordMergeStrategyId,
+                                                                   String 
orderingFieldName,
+                                                                   
HoodieTableVersion tableVersion) {
+    Map<String, String> reconciledConfigs = new HashMap<>();
+    if (tableVersion.versionCode() != HoodieTableVersion.NINE.versionCode()) {
+      return reconciledConfigs;
+    }
+
+    // Step 1: Infer merging configs based on input information.
+    // This step is important since it provides the same configs before we do 
table upgrade.
+    // Then additional logic for table version 9 could be verified.
+    Triple<RecordMergeMode, String, String> inferredConfigs = 
inferBasicMergingBehavior(
+        recordMergeMode, payloadClassName, recordMergeStrategyId, 
orderingFieldName, tableVersion);
+    recordMergeMode = inferredConfigs.getLeft();
+    recordMergeStrategyId = inferredConfigs.getRight();
+
+    // Step 2: Handle Version 9 specific logic.
+    // CASE 0: For tables with special merger properties, e.g., with 
non-builtin mergers.
+    // CASE 1: For tables using MERGE MODE, or CUSTOM builtin mergers.
+    //   NOTE: Payload class should NOT be set for these cases.
+    if (!BUILTIN_MERGE_STRATEGIES.contains(recordMergeStrategyId)
+        || StringUtils.isNullOrEmpty(payloadClassName)) {
+      reconciledConfigs.put(RECORD_MERGE_MODE.key(), recordMergeMode.name());
+      reconciledConfigs.put(RECORD_MERGE_STRATEGY_ID.key(), 
recordMergeStrategyId);
+    } else {
+      // For tables using payload classes.
+      //   CASE 2: Custom payload class. We set these properties explicitly.
+      if (!PAYLOADS_UNDER_DEPRECATION.contains(payloadClassName)) {
+        reconciledConfigs.put(RECORD_MERGE_MODE.key(), CUSTOM.toString());
+        reconciledConfigs.put(PAYLOAD_CLASS_NAME.key(), payloadClassName);
+        reconciledConfigs.put(RECORD_MERGE_STRATEGY_ID.key(), 
PAYLOAD_BASED_MERGE_STRATEGY_UUID);
+      } else { // CASE 3: Payload classes are under deprecation.
+        // Standard merging configs.
+        // NOTE: We use LEGACY_PAYLOAD_CLASS_NAME instead of 
PAYLOAD_CLASS_NAME here.
+        if (EVENT_TIME_BASED_PAYLOADS.contains(payloadClassName)) {
+          reconciledConfigs.put(RECORD_MERGE_MODE.key(), 
EVENT_TIME_ORDERING.name());
+          reconciledConfigs.put(LEGACY_PAYLOAD_CLASS_NAME.key(), 
payloadClassName);
+          reconciledConfigs.put(RECORD_MERGE_STRATEGY_ID.key(), 
EVENT_TIME_BASED_MERGE_STRATEGY_UUID);
+        } else {
+          reconciledConfigs.put(RECORD_MERGE_MODE.key(), 
COMMIT_TIME_ORDERING.name());
+          reconciledConfigs.put(LEGACY_PAYLOAD_CLASS_NAME.key(), 
payloadClassName);
+          reconciledConfigs.put(RECORD_MERGE_STRATEGY_ID.key(), 
COMMIT_TIME_BASED_MERGE_STRATEGY_UUID);
+        }
+        // Partial update mode config.
+        if (payloadClassName.equals(PartialUpdateAvroPayload.class.getName())

Review Comment:
   NIT: Can we add some javadocs on the logic here for partial update and 
custom properties?



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