danny0405 commented on code in PR #11545:
URL: https://github.com/apache/hudi/pull/11545#discussion_r1665134216
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/EightToSevenDowngradeHandler.java:
##########
@@ -32,6 +39,28 @@
public class EightToSevenDowngradeHandler implements DowngradeHandler {
@Override
public Map<ConfigProperty, String> downgrade(HoodieWriteConfig config,
HoodieEngineContext context, String instantTime, SupportsUpgradeDowngrade
upgradeDowngradeHelper) {
+ HoodieTableMetaClient metaClient =
HoodieTableMetaClient.builder().setConf(context.getStorageConf().newInstance()).setBasePath(config.getBasePath()).build();
+ List<HoodieInstant> instants =
metaClient.getActiveTimeline().getInstants();
+ if (!instants.isEmpty()) {
+ context.map(instants, instant -> {
+ if (!instant.getFileName().contains("_")) {
+ return false;
+ }
+ try {
+ // Rename the metadata file name from the
${instant_time}_${completion_time}.action[.state] format in version 1.x to the
${instant_time}.action[.state] format in version 0.x.
+ StoragePath fromPath = new StoragePath(metaClient.getMetaPath(),
instant.getFileName());
+ StoragePath toPath = new StoragePath(metaClient.getMetaPath(),
instant.getFileName().replaceAll("_\\d+", ""));
+ boolean success = metaClient.getStorage().rename(fromPath, toPath);
+ // TODO: We need to rename the action-related part of the metadata
file name here when we bring separate action name for clustering/compaction in
1.x as well.
+ if (!success) {
+ throw new HoodieIOException("Error when rename the instant file: "
+ fromPath + " to: " + toPath);
+ }
+ return true;
+ } catch (IOException e) {
+ throw new HoodieException("Can not to complete the downgrade from
version eight to version seven.", e);
Review Comment:
One thing needs caution here is after the renaming, the file modification
time has changed, the modification time is used as completion time in 0.x
branch.
--
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]