yihua commented on code in PR #8771:
URL: https://github.com/apache/hudi/pull/8771#discussion_r1199677002


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngrade.java:
##########
@@ -105,6 +108,25 @@ public boolean needsUpgradeOrDowngrade(HoodieTableVersion 
toVersion) {
    * @param instantTime current instant time that should not be touched.
    */
   public void run(HoodieTableVersion toVersion, String instantTime) {
+    // Change metadata table version automatically
+    if (toVersion.versionCode() >= HoodieTableVersion.FOUR.versionCode()) {
+      String metadataTablePath = HoodieTableMetadata.getMetadataTableBasePath(
+          metaClient.getBasePathV2().toString());
+      try {
+        if (metaClient.getFs().exists(new Path(metadataTablePath))) {
+          HoodieTableMetaClient mdtMetaClient = HoodieTableMetaClient.builder()
+              
.setConf(metaClient.getHadoopConf()).setBasePath(metadataTablePath).build();
+          HoodieWriteConfig mdtWriteConfig = 
HoodieBackedTableMetadataWriter.createMetadataWriteConfig(
+              config, HoodieFailedWritesCleaningPolicy.LAZY);

Review Comment:
   Yes, the upgrade will also be taken care of.  However, that is not a 
usability issue before this PR, since when writing to a table, before the 
metadata table writer commits to the timeline, it automatically checks if the 
metadata table needs to be upgraded first.



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