wombatu-kun commented on code in PR #20348:
URL: https://github.com/apache/hudi/pull/20348#discussion_r4305380720


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/NineToEightDowngradeHandler.java:
##########
@@ -138,12 +143,37 @@ private void reconcileMergeConfigs(Map<ConfigProperty, 
String> propertiesToAdd,
   private void reconcileOrderingFieldsConfig(Map<ConfigProperty, String> 
propertiesToAdd,
                                              Set<ConfigProperty> 
propertiesToRemove,
                                              HoodieTableConfig tableConfig) {
-    Option<String> orderingFieldsOpt = 
MySqlDebeziumAvroPayload.class.getName().equals(tableConfig.getLegacyPayloadClass())
-        ? Option.of(DebeziumConstants.ADDED_SEQ_COL_NAME)
-        : tableConfig.getOrderingFieldsStr();
-    orderingFieldsOpt.ifPresent(orderingFields -> {
-      propertiesToAdd.put(HoodieTableConfig.PRECOMBINE_FIELD, orderingFields);
+    List<String> orderingFields = 
getOrderingFieldsBelowVersionNine(tableConfig);
+    if (orderingFields.size() == 1) {
+      // the parsed field, so that a stray separator as in `ts,` does not end 
up in a key read as one field name

Review Comment:
   Done 4117a932397f



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/NineToEightDowngradeHandler.java:
##########
@@ -78,6 +82,7 @@ public UpgradeDowngrade.TableConfigChangeSet 
downgrade(HoodieWriteConfig config,
                                                          
SupportsUpgradeDowngrade upgradeDowngradeHelper) {
     final HoodieTable table = upgradeDowngradeHelper.getTable(config, context);
     HoodieTableMetaClient metaClient = table.getMetaClient();
+    validateOrderingFields(metaClient.getTableConfig(), 
HoodieTableVersion.EIGHT);

Review Comment:
   Done 4117a932397f. Only `UpgradeDowngrade.run` checks now, so a 10 to 6 
request reports version 6, which `TestUpgradeDowngradeOrchestration` now covers.



##########
hudi-client/hudi-client-common/src/test/java/org/apache/hudi/table/upgrade/TestNineToEightDowngradeHandler.java:
##########
@@ -251,6 +253,42 @@ void testDowngradeForOtherPayloadClass() {
     }
   }
 
+  @Test
+  void testDowngradeRefusesSeveralOrderingFields() {
+    try (MockedStatic<UpgradeDowngradeUtils> utilities = 
Mockito.mockStatic(UpgradeDowngradeUtils.class)) {
+      when(tableConfig.getOrderingFieldsStr()).thenReturn(Option.of("ts,seq"));
+      HoodieUpgradeDowngradeException exception = 
assertThrows(HoodieUpgradeDowngradeException.class,
+          () -> handler.downgrade(config, context, "anyInstant", 
upgradeDowngradeHelper));
+      assertEquals("Cannot downgrade to table version 8: 
hoodie.table.ordering.fields=ts,seq orders records on several fields, "

Review Comment:
   Done 4117a932397f. No test asserts the whole message now: this test went 
away with the handler check, and `TestUpgradeDowngrade` matches the same 
leading part as the orchestration test, target version included.



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