[HUDI-4495] Fix handling of S3 paths incompatible with java URI standards (#6237)
This commit is contained in:
@@ -145,8 +145,11 @@ public class HoodieWrapperFileSystem extends FileSystem {
|
|||||||
URI oldURI = oldPath.toUri();
|
URI oldURI = oldPath.toUri();
|
||||||
URI newURI;
|
URI newURI;
|
||||||
try {
|
try {
|
||||||
newURI = new URI(newScheme, oldURI.getUserInfo(), oldURI.getHost(), oldURI.getPort(), oldURI.getPath(),
|
newURI = new URI(newScheme,
|
||||||
oldURI.getQuery(), oldURI.getFragment());
|
oldURI.getAuthority(),
|
||||||
|
oldURI.getPath(),
|
||||||
|
oldURI.getQuery(),
|
||||||
|
oldURI.getFragment());
|
||||||
return new CachingPath(newURI);
|
return new CachingPath(newURI);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
// TODO - Better Exception handling
|
// TODO - Better Exception handling
|
||||||
|
|||||||
@@ -18,8 +18,10 @@
|
|||||||
|
|
||||||
package org.apache.hudi.common.fs;
|
package org.apache.hudi.common.fs;
|
||||||
|
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -54,4 +56,19 @@ public class TestStorageSchemes {
|
|||||||
StorageSchemes.isAppendSupported("s2");
|
StorageSchemes.isAppendSupported("s2");
|
||||||
}, "Should throw exception for unsupported schemes");
|
}, "Should throw exception for unsupported schemes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConversionToNewSchema() {
|
||||||
|
Path s3TablePath1 = new Path("s3://test.1234/table1");
|
||||||
|
assertEquals(s3TablePath1, HoodieWrapperFileSystem.convertPathWithScheme(s3TablePath1, "s3"));
|
||||||
|
|
||||||
|
Path s3TablePath2 = new Path("s3://1234.test/table1");
|
||||||
|
assertEquals(s3TablePath2, HoodieWrapperFileSystem.convertPathWithScheme(s3TablePath2, "s3"));
|
||||||
|
|
||||||
|
Path s3TablePath3 = new Path("s3://test1234/table1");
|
||||||
|
assertEquals(s3TablePath3, HoodieWrapperFileSystem.convertPathWithScheme(s3TablePath3, "s3"));
|
||||||
|
|
||||||
|
Path hdfsTablePath = new Path("hdfs://sandbox.foo.com:8020/test.1234/table1");
|
||||||
|
System.out.println(HoodieWrapperFileSystem.convertPathWithScheme(hdfsTablePath, "hdfs"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user