branch-2.1: [fix](external)fix split and get the schema #45408 (#45566)

Cherry-picked from #45408

Co-authored-by: wuwenchi <wuwenchi@selectdb.com>
This commit is contained in:
github-actions[bot]
2024-12-19 14:06:36 +08:00
committed by GitHub
parent 7d32e4f71f
commit 90ca889f84
2 changed files with 13 additions and 1 deletions

View File

@ -90,7 +90,7 @@ public class LocationPath {
private LocationPath(String originLocation, Map<String, String> props, boolean convertPath) {
isBindBroker = props.containsKey(HMSExternalCatalog.BIND_BROKER_NAME);
String tmpLocation = originLocation;
if (!originLocation.contains(SCHEME_DELIM)) {
if (!(originLocation.contains(SCHEME_DELIM) || originLocation.contains(NONSTANDARD_SCHEME_DELIM))) {
// Sometimes the file path does not contain scheme, need to add default fs
// eg, /path/to/file.parquet -> hdfs://nn/path/to/file.parquet
// the default fs is from the catalog properties

View File

@ -205,4 +205,16 @@ public class LocationPathTest {
String beLocation = locationPath.toStorageLocation().toString();
Assertions.assertTrue(beLocation.equalsIgnoreCase("/path/to/local"));
}
@Test
public void testLocalFileSystem() {
HashMap<String, String> props = new HashMap<>();
props.put("fs.defaultFS", "hdfs:///xyz");
LocationPath p1 = new LocationPath("file:///abc/def", props);
Assertions.assertEquals(Scheme.LOCAL, p1.getScheme());
LocationPath p2 = new LocationPath("file:/abc/def", props);
Assertions.assertEquals(Scheme.LOCAL, p2.getScheme());
LocationPath p3 = new LocationPath("file://authority/abc/def", props);
Assertions.assertEquals(Scheme.LOCAL, p3.getScheme());
}
}