rahil-c commented on code in PR #13687:
URL: https://github.com/apache/hudi/pull/13687#discussion_r2265100781


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngrade.java:
##########
@@ -90,14 +90,34 @@ public static boolean 
needsUpgradeOrDowngrade(HoodieTableMetaClient metaClient,
 
   public static boolean needsUpgrade(HoodieTableMetaClient metaClient, 
HoodieWriteConfig config, HoodieTableVersion toWriteVersion) {
     HoodieTableVersion fromTableVersion = 
metaClient.getTableConfig().getTableVersion();
-    // If table version is less than SIX, then we need to upgrade to SIX first 
before upgrading to any other version, irrespective of autoUpgrade flag
+    if (fromTableVersion.versionCode() >= toWriteVersion.versionCode()) {
+      // if the table version is greater than or equal to the write version, 
then this is not an upgrade
+      LOG.warn("Table version {} is greater than or equal to write version {}. 
No upgrade needed", fromTableVersion, toWriteVersion);

Review Comment:
   I do not think an exception should be thrown, the reason is this method 
needsUpgrade, can be called in the method 
   `needsUpgradeOrDowngrade` to just determine if its an upgrade or a downgrade.
   ```
   public static boolean needsUpgradeOrDowngrade(HoodieTableMetaClient 
metaClient, HoodieWriteConfig config, HoodieTableVersion toWriteVersion) {
       HoodieTableVersion fromTableVersion = 
metaClient.getTableConfig().getTableVersion();
       return needsUpgrade(metaClient, config, toWriteVersion) || 
toWriteVersion.versionCode() < fromTableVersion.versionCode();
     }
   ```
   which is used in a couple of areas.
   <img width="1496" height="208" alt="Screenshot 2025-08-09 at 8 46 20 PM" 
src="https://github.com/user-attachments/assets/e4f7d5ea-c9ad-412f-a6b5-64a8723ae43b";
 />
   
   I can try adding a test for this if needed.



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