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


##########
hudi-client/hudi-client-common/src/test/java/org/apache/hudi/table/upgrade/TestSevenToEightUpgradeHandler.java:
##########
@@ -122,4 +115,42 @@ void testPropertyUpgrade() {
     assertTrue(tablePropsToAdd.containsKey(KEY_GENERATOR_CLASS_NAME));
     assertTrue(tablePropsToAdd.containsKey(KEY_GENERATOR_TYPE));
   }
+
+  @ParameterizedTest
+  @CsvSource({
+      "com.example.CustomPayload, , CUSTOM, 
00000000-0000-0000-0000-000000000000, com.example.CustomPayload",
+      "com.example.CustomPayload, preCombineFieldValue, CUSTOM, 
00000000-0000-0000-0000-000000000000, com.example.CustomPayload",
+      "org.apache.hudi.common.model.OverwriteWithLatestAvroPayload, , 
COMMIT_TIME_ORDERING, ce9acb64-bde0-424c-9b91-f6ebba25356d, 
org.apache.hudi.common.model.OverwriteWithLatestAvroPayload",
+      "org.apache.hudi.common.model.DefaultHoodieRecordPayload, , 
EVENT_TIME_ORDERING, eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      ", preCombineFieldValue, EVENT_TIME_ORDERING, 
eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      "org.apache.hudi.common.model.OverwriteWithLatestAvroPayload, 
preCombineFieldValue, EVENT_TIME_ORDERING,"
+          + " eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      ", preCombineFieldValue, EVENT_TIME_ORDERING, 
eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      "org.apache.hudi.common.model.DefaultHoodieRecordPayload, 
preCombineFieldValue, EVENT_TIME_ORDERING,"
+          + " eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      ", , COMMIT_TIME_ORDERING, ce9acb64-bde0-424c-9b91-f6ebba25356d, 
org.apache.hudi.common.model.OverwriteWithLatestAvroPayload"

Review Comment:
   Addressed



##########
hudi-client/hudi-client-common/src/test/java/org/apache/hudi/table/upgrade/TestSevenToEightUpgradeHandler.java:
##########
@@ -122,4 +115,42 @@ void testPropertyUpgrade() {
     assertTrue(tablePropsToAdd.containsKey(KEY_GENERATOR_CLASS_NAME));
     assertTrue(tablePropsToAdd.containsKey(KEY_GENERATOR_TYPE));
   }
+
+  @ParameterizedTest
+  @CsvSource({
+      "com.example.CustomPayload, , CUSTOM, 
00000000-0000-0000-0000-000000000000, com.example.CustomPayload",
+      "com.example.CustomPayload, preCombineFieldValue, CUSTOM, 
00000000-0000-0000-0000-000000000000, com.example.CustomPayload",
+      "org.apache.hudi.common.model.OverwriteWithLatestAvroPayload, , 
COMMIT_TIME_ORDERING, ce9acb64-bde0-424c-9b91-f6ebba25356d, 
org.apache.hudi.common.model.OverwriteWithLatestAvroPayload",
+      "org.apache.hudi.common.model.DefaultHoodieRecordPayload, , 
EVENT_TIME_ORDERING, eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      ", preCombineFieldValue, EVENT_TIME_ORDERING, 
eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      "org.apache.hudi.common.model.OverwriteWithLatestAvroPayload, 
preCombineFieldValue, EVENT_TIME_ORDERING,"
+          + " eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      ", preCombineFieldValue, EVENT_TIME_ORDERING, 
eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      "org.apache.hudi.common.model.DefaultHoodieRecordPayload, 
preCombineFieldValue, EVENT_TIME_ORDERING,"
+          + " eeb8d96f-b1e4-49fd-bbf8-28ac514178e5, 
org.apache.hudi.common.model.DefaultHoodieRecordPayload",
+      ", , COMMIT_TIME_ORDERING, ce9acb64-bde0-424c-9b91-f6ebba25356d, 
org.apache.hudi.common.model.OverwriteWithLatestAvroPayload"
+  })
+  void testUpgradeMergeMode(String payloadClass, String preCombineField, 
String expectedMergeMode, String expectedStrategy, String expectedPayloadClass) 
{
+    HoodieTableConfig tableConfig = Mockito.mock(HoodieTableConfig.class);
+    Map<ConfigProperty, String> tablePropsToAdd = new HashMap<>();
+
+    when(tableConfig.getPayloadClass()).thenReturn(payloadClass);
+    when(tableConfig.getPreCombineField()).thenReturn(preCombineField);
+
+    SevenToEightUpgradeHandler.upgradeMergeMode(tableConfig, tablePropsToAdd);
+
+    assertEquals(expectedMergeMode, 
tablePropsToAdd.get(HoodieTableConfig.RECORD_MERGE_MODE));
+    assertEquals(expectedStrategy, 
tablePropsToAdd.get(HoodieTableConfig.RECORD_MERGE_STRATEGY_ID));
+    if (expectedPayloadClass != null) {
+      assertEquals(expectedPayloadClass, 
tablePropsToAdd.get(HoodieTableConfig.PAYLOAD_CLASS_NAME));
+    }

Review Comment:
   Addressed



##########
hudi-client/hudi-client-common/src/test/java/org/apache/hudi/table/upgrade/TestSevenToEightUpgradeHandler.java:
##########
@@ -122,4 +115,42 @@ void testPropertyUpgrade() {
     assertTrue(tablePropsToAdd.containsKey(KEY_GENERATOR_CLASS_NAME));
     assertTrue(tablePropsToAdd.containsKey(KEY_GENERATOR_TYPE));
   }
+
+  @ParameterizedTest
+  @CsvSource({
+      "com.example.CustomPayload, , CUSTOM, 
00000000-0000-0000-0000-000000000000, com.example.CustomPayload",
+      "com.example.CustomPayload, preCombineFieldValue, CUSTOM, 
00000000-0000-0000-0000-000000000000, com.example.CustomPayload",

Review Comment:
   Addressed



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/EightToSevenDowngradeHandler.java:
##########
@@ -133,7 +138,7 @@ public Map<ConfigProperty, String> 
downgrade(HoodieWriteConfig config, HoodieEng
     // downgrade table properties
     downgradePartitionFields(config, metaClient.getTableConfig(), 
tablePropsToAdd);
     unsetInitialVersion(metaClient.getTableConfig(), tablePropsToAdd);
-    unsetRecordMergeMode(metaClient.getTableConfig(), tablePropsToAdd);
+    List<ConfigProperty> configsToRemove = unsetRecordMergeMode(config, 
metaClient.getTableConfig(), tablePropsToAdd);

Review Comment:
   Addressed



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

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

Reply via email to