Skip to content

Commit

Permalink
[HUDI-4495] Fix handling of S3 paths incompatible with java URI stand…
Browse files Browse the repository at this point in the history
…ards (#6237)
  • Loading branch information
umehrot2 committed Jul 29, 2022
1 parent cfd0c1e commit c39e88d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ public static Path convertPathWithScheme(Path oldPath, String newScheme) {
URI oldURI = oldPath.toUri();
URI newURI;
try {
newURI = new URI(newScheme, oldURI.getUserInfo(), oldURI.getHost(), oldURI.getPort(), oldURI.getPath(),
oldURI.getQuery(), oldURI.getFragment());
newURI = new URI(newScheme,
oldURI.getAuthority(),
oldURI.getPath(),
oldURI.getQuery(),
oldURI.getFragment());
return new CachingPath(newURI);
} catch (URISyntaxException e) {
// TODO - Better Exception handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

package org.apache.hudi.common.fs;

import org.apache.hadoop.fs.Path;
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.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -54,4 +56,19 @@ public void testStorageSchemes() {
StorageSchemes.isAppendSupported("s2");
}, "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"));
}
}

0 comments on commit c39e88d

Please sign in to comment.