You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "cshuo (via GitHub)" <gi...@apache.org> on 2026/07/06 11:39:35 UTC

[PR] feat: Support table version 10 to 9 downgrade [hudi]

cshuo opened a new pull request, #19199:
URL: https://github.com/apache/hudi/pull/19199

   ### Describe the issue this Pull Request addresses
   
   Table version 10 enables native log files by default, but table version 9 readers do not understand native log files. Downgrading a v10 MOR table to v9 must therefore ensure native data/delete logs are compacted away before the downgrade completes.
   
   Native CDC log conversion is intentionally out of scope for this downgrade path because v9 cannot read native `.cdc.parquet` files and converting them to legacy inline CDC logs would add broader CDC correctness and schema-evolution risk.
   
   ### Summary and Changelog
   
   - Added `TenToNineDowngradeHandler` to remove the v10-only `hoodie.table.storage.layout` table config during downgrade.
   - Wired `TEN -> NINE` downgrade routing in `UpgradeDowngrade` and added `(10, 9)` to the rollback-and-compact preflight set so native data/delete logs are compacted before v9 exposure.
   - Added native CDC fail-fast validation before rollback/compaction using native CDC filename detection.
   - Added `FSUtils.isNativeCDCLogFile(...)` support for identifying native CDC logs.
   - Added unit coverage for the 10-to-9 handler, route support, table config cleanup, and native CDC validation.
   - Added Spark downgrade coverage for v10 MOR tables with native logs, including validation that logs are compacted and storage layout config is removed.
   - Added Spark coverage for native CDC fail-fast behavior.
   - Removed temporary issue-19090 test workarounds that pinned writes to v9 now that 10-to-9 downgrade is supported.
   - Re-enabled Flink compactor downgrade coverage.
   - Extended existing current-plus-lower-version test matrices to include table version 9.
   
   ### Impact
   
   - **Functional impact**: Tables can now downgrade from version 10 to version 9 when native data/delete logs can be compacted away. Downgrade fails fast if native CDC logs are present.
   - **Maintainability**: Keeps v10-specific cleanup in a dedicated downgrade handler and reuses existing rollback-and-compaction downgrade preflight behavior.
   - **Extensibility**: Leaves native CDC downgrade conversion out of scope, preserving a clear future extension point if native-to-legacy CDC conversion is later designed.
   
   ### Risk Level
   
   medium. This touches core upgrade/downgrade routing and table-service preflight behavior, but the scope is limited to the new 10-to-9 downgrade path. Risk is mitigated by new handler tests, Spark integration coverage for native log compaction and CDC fail-fast, and cleanup of tests that previously avoided the unsupported downgrade path.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Enough context is provided in the sections above
   - [ ] Adequate tests were added if applicable


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19199:
URL: https://github.com/apache/hudi/pull/19199#discussion_r3535400244


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/TenToNineDowngradeHandler.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.table.upgrade;
+
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+
+import java.util.Collections;
+
+/**
+ * Version 10 writes native log files by default. Downgrading to version 9 requires
+ * full compaction of native data/delete logs before the downgrade completes.

Review Comment:
   🤖 With the native-CDC guard removed, committed `.cdc.parquet` files now survive a 10→9 downgrade — `rollbackFailedWritesAndCompact` only merges data/delete logs, not CDC logs — so they'd remain after the table is stamped v9, which per the PR description v9 can't read, silently breaking CDC incremental reads. Rather than dropping the check entirely (I know the earlier concern was over-blocking on orphan files), could it instead run after `rollbackFailedWrites` so only committed CDC logs fail fast? Or is CDC-log downgrade being descoped to a follow-up?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4892600726

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * bf1e02e3d25ebaa941f1b7f13267938531e2c7c5 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4892394258

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * bf1e02e3d25ebaa941f1b7f13267938531e2c7c5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4901080310

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311",
       "triggerID" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dd4a63ce23a136413f5792dd5226e3cec1f4a96c",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15327",
       "triggerID" : "dd4a63ce23a136413f5792dd5226e3cec1f4a96c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 0efa9b4ea4499932209f8ab6e16228af8ed791f3 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285) 
   * cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311) 
   * dd4a63ce23a136413f5792dd5226e3cec1f4a96c Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15327) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4901039258

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311",
       "triggerID" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dd4a63ce23a136413f5792dd5226e3cec1f4a96c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "dd4a63ce23a136413f5792dd5226e3cec1f4a96c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 0efa9b4ea4499932209f8ab6e16228af8ed791f3 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285) 
   * cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311) 
   * dd4a63ce23a136413f5792dd5226e3cec1f4a96c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19199:
URL: https://github.com/apache/hudi/pull/19199#discussion_r3533025256


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngrade.java:
##########
@@ -183,6 +184,8 @@ public void run(HoodieTableVersion toVersion, String instantTime) {
       return;
     }
 
+    validateDowngradePrerequisites(fromVersion, toVersion, isUpgrade);

Review Comment:
   🤖 The native CDC scan in `validateDowngradePrerequisites` runs here, before `performRollbackAndCompactionIfRequired` rolls back failed/inflight writes. If a native `.cdc.parquet` file is left over from an uncommitted write, wouldn't that block the downgrade even though the rollback on the next line would have cleaned it up? Might be worth running `validateNoNativeCdcLogs` after `rollbackFailedWrites` (still before compaction) so only committed CDC logs fail fast.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/TenToNineDowngradeHandler.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.table.upgrade;
+
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieUpgradeDowngradeException;
+import org.apache.hudi.storage.StoragePath;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Version 10 writes native log files by default. Downgrading to version 9 requires
+ * full compaction of native data/delete logs before the downgrade completes. Native
+ * CDC log conversion is intentionally unsupported.
+ */
+public class TenToNineDowngradeHandler implements DowngradeHandler {
+  @Override
+  public UpgradeDowngrade.TableConfigChangeSet downgrade(
+      HoodieWriteConfig config,
+      HoodieEngineContext context,
+      String instantTime,
+      SupportsUpgradeDowngrade upgradeDowngradeHelper) {
+    return new UpgradeDowngrade.TableConfigChangeSet(
+        Collections.emptyMap(),
+        Collections.singleton(HoodieTableConfig.TABLE_STORAGE_LAYOUT));
+  }
+
+  static void validateNoNativeCdcLogs(HoodieTableMetaClient metaClient) {
+    findNativeCdcLogFile(metaClient).ifPresent(nativeCdcLogFile -> {
+      throw new HoodieUpgradeDowngradeException(String.format(
+          "Cannot downgrade table from version 10 to 9 because native CDC log file %s exists. "
+              + "Native CDC log downgrade is unsupported.",
+          nativeCdcLogFile));
+    });
+  }
+
+  static Option<StoragePath> findNativeCdcLogFile(HoodieTableMetaClient metaClient) {
+    AtomicReference<StoragePath> nativeCdcLogFile = new AtomicReference<>();
+    try {
+      FSUtils.processFiles(metaClient.getStorage(), metaClient.getBasePath().toString(), pathInfo -> {
+        if (pathInfo.isFile() && FSUtils.isNativeCDCLogFile(pathInfo.getPath().getName())) {
+          nativeCdcLogFile.set(pathInfo.getPath());
+          return false;
+        }
+        return true;
+      }, true);
+    } catch (IOException e) {
+      throw new HoodieUpgradeDowngradeException(
+          "Failed to scan table for native CDC log files before downgrading from version 10 to 9", e);
+    } catch (HoodieException e) {

Review Comment:
   🤖 nit: the `HoodieException` catch is swallowed silently when `nativeCdcLogFile.get() != null` — could you add a brief comment explaining that `FSUtils.processFiles` throws a `HoodieException` when the callback returns `false` (early-exit signal), so catching and discarding it here is intentional? Without that context, this reads like exception suppression.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/TenToNineDowngradeHandler.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.table.upgrade;
+
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieUpgradeDowngradeException;
+import org.apache.hudi.storage.StoragePath;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Version 10 writes native log files by default. Downgrading to version 9 requires
+ * full compaction of native data/delete logs before the downgrade completes. Native
+ * CDC log conversion is intentionally unsupported.
+ */
+public class TenToNineDowngradeHandler implements DowngradeHandler {
+  @Override
+  public UpgradeDowngrade.TableConfigChangeSet downgrade(
+      HoodieWriteConfig config,
+      HoodieEngineContext context,
+      String instantTime,
+      SupportsUpgradeDowngrade upgradeDowngradeHelper) {
+    return new UpgradeDowngrade.TableConfigChangeSet(
+        Collections.emptyMap(),
+        Collections.singleton(HoodieTableConfig.TABLE_STORAGE_LAYOUT));
+  }
+
+  static void validateNoNativeCdcLogs(HoodieTableMetaClient metaClient) {
+    findNativeCdcLogFile(metaClient).ifPresent(nativeCdcLogFile -> {
+      throw new HoodieUpgradeDowngradeException(String.format(
+          "Cannot downgrade table from version 10 to 9 because native CDC log file %s exists. "
+              + "Native CDC log downgrade is unsupported.",
+          nativeCdcLogFile));
+    });
+  }
+
+  static Option<StoragePath> findNativeCdcLogFile(HoodieTableMetaClient metaClient) {
+    AtomicReference<StoragePath> nativeCdcLogFile = new AtomicReference<>();
+    try {
+      FSUtils.processFiles(metaClient.getStorage(), metaClient.getBasePath().toString(), pathInfo -> {
+        if (pathInfo.isFile() && FSUtils.isNativeCDCLogFile(pathInfo.getPath().getName())) {
+          nativeCdcLogFile.set(pathInfo.getPath());
+          return false;
+        }
+        return true;
+      }, true);
+    } catch (IOException e) {
+      throw new HoodieUpgradeDowngradeException(
+          "Failed to scan table for native CDC log files before downgrading from version 10 to 9", e);
+    } catch (HoodieException e) {
+      if (nativeCdcLogFile.get() == null) {
+        throw e;
+      }
+    }
+    return nativeCdcLogFile.get() == null ? Option.empty() : Option.of(nativeCdcLogFile.get());

Review Comment:
   🤖 nit: `nativeCdcLogFile.get()` is called twice on the same line — extracting it to a local `StoragePath found = nativeCdcLogFile.get()` before the return would be slightly cleaner.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngrade.java:
##########
@@ -408,4 +413,26 @@ private void performRollbackAndCompactionIfRequired(HoodieTableVersion fromVersi
           tableVersion);
     }
   }
+
+  /**
+   * Checks if any handlers in the downgrade path require validation before rollback and compaction.
+   *
+   * @param fromVersion the current table version
+   * @param toVersion   the target table version
+   * @param isUpgrade   whether the current operation is an upgrade
+   */
+  private void validateDowngradePrerequisites(HoodieTableVersion fromVersion, HoodieTableVersion toVersion, boolean isUpgrade) {
+    if (isUpgrade) {
+      return;
+    }
+
+    HoodieTableVersion checkVersion = fromVersion;
+    while (checkVersion.versionCode() > toVersion.versionCode()) {
+      HoodieTableVersion prevVersion = HoodieTableVersion.fromVersionCode(checkVersion.versionCode() - 1);
+      if (checkVersion == HoodieTableVersion.TEN && prevVersion == HoodieTableVersion.NINE) {

Review Comment:
   🤖 nit: `prevVersion == HoodieTableVersion.NINE` is always true when `checkVersion == TEN` (since `prevVersion` is computed as `checkVersion - 1`), so the second clause is redundant and might make a reader wonder if there's an edge case where it could differ. `if (checkVersion == HoodieTableVersion.TEN)` alone would be clearer.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4901122395

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311",
       "triggerID" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dd4a63ce23a136413f5792dd5226e3cec1f4a96c",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15327",
       "triggerID" : "dd4a63ce23a136413f5792dd5226e3cec1f4a96c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311) 
   * dd4a63ce23a136413f5792dd5226e3cec1f4a96c Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15327) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19199:
URL: https://github.com/apache/hudi/pull/19199#discussion_r3528668519


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/TenToNineDowngradeHandler.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.table.upgrade;
+
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieUpgradeDowngradeException;
+import org.apache.hudi.storage.StoragePath;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Version 10 writes native log files by default. Downgrading to version 9 requires
+ * full compaction of native data/delete logs before the downgrade completes. Native
+ * CDC log conversion is intentionally unsupported.
+ */
+public class TenToNineDowngradeHandler implements DowngradeHandler {
+  @Override
+  public UpgradeDowngrade.TableConfigChangeSet downgrade(
+      HoodieWriteConfig config,
+      HoodieEngineContext context,
+      String instantTime,
+      SupportsUpgradeDowngrade upgradeDowngradeHelper) {
+    return new UpgradeDowngrade.TableConfigChangeSet(
+        Collections.emptyMap(),
+        Collections.singleton(HoodieTableConfig.TABLE_STORAGE_LAYOUT));
+  }
+
+  static void validateNoNativeCdcLogs(HoodieTableMetaClient metaClient) {

Review Comment:
   🤖 nit: could you rename `validateNoNativeCdcLogs` → `validateNoNativeCDCLogs` (and `findNativeCdcLogFile` → `findNativeCDCLogFile` on line 61)? The adjacent call to `FSUtils.isNativeCDCLogFile` uses all-caps `CDC`, and so does the existing `isCDCLogFile` — mixing `Cdc` here creates a small but real inconsistency that'll show up in searches and diffs.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/TenToNineDowngradeHandler.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.table.upgrade;
+
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieUpgradeDowngradeException;
+import org.apache.hudi.storage.StoragePath;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Version 10 writes native log files by default. Downgrading to version 9 requires
+ * full compaction of native data/delete logs before the downgrade completes. Native
+ * CDC log conversion is intentionally unsupported.
+ */
+public class TenToNineDowngradeHandler implements DowngradeHandler {
+  @Override
+  public UpgradeDowngrade.TableConfigChangeSet downgrade(
+      HoodieWriteConfig config,
+      HoodieEngineContext context,
+      String instantTime,
+      SupportsUpgradeDowngrade upgradeDowngradeHelper) {
+    return new UpgradeDowngrade.TableConfigChangeSet(
+        Collections.emptyMap(),
+        Collections.singleton(HoodieTableConfig.TABLE_STORAGE_LAYOUT));
+  }
+
+  static void validateNoNativeCdcLogs(HoodieTableMetaClient metaClient) {
+    findNativeCdcLogFile(metaClient).ifPresent(nativeCdcLogFile -> {
+      throw new HoodieUpgradeDowngradeException(String.format(
+          "Cannot downgrade table from version 10 to 9 because native CDC log file %s exists. "
+              + "Native CDC log downgrade is unsupported.",
+          nativeCdcLogFile));
+    });
+  }
+
+  static Option<StoragePath> findNativeCdcLogFile(HoodieTableMetaClient metaClient) {
+    AtomicReference<StoragePath> nativeCdcLogFile = new AtomicReference<>();
+    try {
+      FSUtils.processFiles(metaClient.getStorage(), metaClient.getBasePath().toString(), pathInfo -> {
+        if (pathInfo.isFile() && FSUtils.isNativeCDCLogFile(pathInfo.getPath().getName())) {
+          nativeCdcLogFile.set(pathInfo.getPath());
+          return false;
+        }
+        return true;
+      }, true);
+    } catch (IOException e) {
+      throw new HoodieUpgradeDowngradeException(
+          "Failed to scan table for native CDC log files before downgrading from version 10 to 9", e);
+    } catch (HoodieException e) {

Review Comment:
   🤖 nit: it might be worth adding a brief comment here explaining why the `HoodieException` is intentionally swallowed — e.g. `// processFiles throws HoodieException when the callback returns false for early exit; if we already found a CDC log, that's the expected path and the exception can be ignored`. Without it, future readers will almost certainly assume this is an accidental swallow.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngrade.java:
##########
@@ -408,4 +413,26 @@ private void performRollbackAndCompactionIfRequired(HoodieTableVersion fromVersi
           tableVersion);
     }
   }
+
+  /**
+   * Checks if any handlers in the downgrade path require validation before rollback and compaction.
+   *
+   * @param fromVersion the current table version
+   * @param toVersion   the target table version
+   * @param isUpgrade   whether the current operation is an upgrade
+   */
+  private void validateDowngradePrerequisites(HoodieTableVersion fromVersion, HoodieTableVersion toVersion, boolean isUpgrade) {
+    if (isUpgrade) {
+      return;
+    }
+
+    HoodieTableVersion checkVersion = fromVersion;
+    while (checkVersion.versionCode() > toVersion.versionCode()) {
+      HoodieTableVersion prevVersion = HoodieTableVersion.fromVersionCode(checkVersion.versionCode() - 1);
+      if (checkVersion == HoodieTableVersion.TEN && prevVersion == HoodieTableVersion.NINE) {

Review Comment:
   🤖 nit: `prevVersion == HoodieTableVersion.NINE` is always true when `checkVersion == TEN` because `prevVersion` is computed as `checkVersion.versionCode() - 1` on the line above. Could you simplify to just `if (checkVersion == HoodieTableVersion.TEN)` to avoid the misleading impression that there's a meaningful independent check here?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4899168113

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * bf1e02e3d25ebaa941f1b7f13267938531e2c7c5 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264) 
   * 0efa9b4ea4499932209f8ab6e16228af8ed791f3 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 merged PR #19199:
URL: https://github.com/apache/hudi/pull/19199


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4892432177

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * bf1e02e3d25ebaa941f1b7f13267938531e2c7c5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4899736609

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 0efa9b4ea4499932209f8ab6e16228af8ed791f3 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285) 
   * cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4899198816

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 0efa9b4ea4499932209f8ab6e16228af8ed791f3 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] feat: Support table version 10 to 9 downgrade [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19199:
URL: https://github.com/apache/hudi/pull/19199#issuecomment-4899768067

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15264",
       "triggerID" : "bf1e02e3d25ebaa941f1b7f13267938531e2c7c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285",
       "triggerID" : "0efa9b4ea4499932209f8ab6e16228af8ed791f3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311",
       "triggerID" : "cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 0efa9b4ea4499932209f8ab6e16228af8ed791f3 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15285) 
   * cee25c5a7f62dc2f9fc0656f7dcb2a136f370d5a Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15311) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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