1
0

[HUDI-400] Check upgrade from old plan to new plan for compaction (#1422)

* Fix NPE when DataFile is null
* Check from old plan upgrade to new plan
This commit is contained in:
Zhiyuan Zhao
2020-03-20 15:13:17 +08:00
committed by GitHub
parent a752b7b18c
commit 14e0c95206
2 changed files with 3 additions and 1 deletions

View File

@@ -55,7 +55,7 @@ public class CompactionV2MigrationHandler extends AbstractMigratorBase<HoodieCom
v2CompactionOperationList = input.getOperations().stream().map(inp ->
HoodieCompactionOperation.newBuilder().setBaseInstantTime(inp.getBaseInstantTime())
.setFileId(inp.getFileId()).setPartitionPath(inp.getPartitionPath()).setMetrics(inp.getMetrics())
.setDataFilePath(new Path(inp.getDataFilePath()).getName()).setDeltaFilePaths(
.setDataFilePath(inp.getDataFilePath() == null ? null : new Path(inp.getDataFilePath()).getName()).setDeltaFilePaths(
inp.getDeltaFilePaths().stream().map(s -> new Path(s).getName()).collect(Collectors.toList()))
.build()).collect(Collectors.toList());
}

View File

@@ -84,6 +84,8 @@ public class TestCompactionUtils extends HoodieCommonTestHarness {
HoodieCompactionPlan newPlan = migrator.upgradeToLatest(plan, plan.getVersion());
Assert.assertEquals(LATEST_COMPACTION_METADATA_VERSION, newPlan.getVersion());
testFileSlicesCompactionPlanEquality(inputAndPlan.getKey(), newPlan);
HoodieCompactionPlan latestPlan = migrator.migrateToVersion(oldPlan, oldPlan.getVersion(), newPlan.getVersion());
testFileSlicesCompactionPlanEquality(inputAndPlan.getKey(), latestPlan);
}
@Test