From db3cea99b69fc12dd7807afa8d67f04d2dab85ef Mon Sep 17 00:00:00 2001 From: Ryan Pifer Date: Mon, 28 Dec 2020 12:30:44 -0800 Subject: [PATCH] [RFC-15] Fix partition key in metadata table when bootstrapping from file system --- .../apache/hudi/metadata/HoodieBackedTableMetadataWriter.java | 3 ++- .../org/apache/hudi/metadata/TestHoodieBackedMetadata.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hudi-client/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java b/hudi-client/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java index c3ba2a9ec5949..fa67766c2cca4 100644 --- a/hudi-client/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java +++ b/hudi-client/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java @@ -374,7 +374,8 @@ private Map> getPartitionsToFilesMapping(JavaSparkConte if (p.getRight().length > filesInDir.size()) { // Is a partition. Add all data files to result. - partitionToFileStatus.put(p.getLeft().getName(), filesInDir); + String partitionName = FSUtils.getRelativePartitionPath(new Path(datasetMetaClient.getBasePath()), p.getLeft()); + partitionToFileStatus.put(partitionName, filesInDir); } else { // Add sub-dirs to the queue pathsToList.addAll(Arrays.stream(p.getRight()) diff --git a/hudi-client/src/test/java/org/apache/hudi/metadata/TestHoodieBackedMetadata.java b/hudi-client/src/test/java/org/apache/hudi/metadata/TestHoodieBackedMetadata.java index 48d07e57cbae1..1bb1081f0c98e 100644 --- a/hudi-client/src/test/java/org/apache/hudi/metadata/TestHoodieBackedMetadata.java +++ b/hudi-client/src/test/java/org/apache/hudi/metadata/TestHoodieBackedMetadata.java @@ -73,7 +73,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.ValueSource; public class TestHoodieBackedMetadata extends HoodieClientTestHarness { @@ -406,6 +405,7 @@ public void testRollbackUnsyncedCommit() throws Exception { //@ParameterizedTest //@EnumSource(HoodieTableType.class) //public void testSync(HoodieTableType tableType) throws Exception { + @Test public void testSync() throws Exception { //FIXME(metadata): This is broken for MOR, until HUDI-1434 is fixed init(HoodieTableType.COPY_ON_WRITE);