Skip to content

Commit b12f461

Browse files
committed
Using the locationWithoutScheme for use in withoutScheme method and another minor change
1 parent 53989d4 commit b12f461

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

polaris-core/src/main/java/org/apache/polaris/core/storage/aws/S3Location.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import org.apache.polaris.core.storage.StorageLocation;
2626

2727
public class S3Location extends StorageLocation {
28-
private static final Pattern URI_PATTERN = Pattern.compile("^(s3a?)://(.+)$");
28+
private static final Pattern URI_PATTERN = Pattern.compile("^(s3a?):(.+)$");
2929
private final String scheme;
30-
private final String objectKeyWBucket;
30+
private final String locationWithoutScheme;
3131

3232
public S3Location(@Nonnull String location) {
3333
super(location);
@@ -36,7 +36,7 @@ public S3Location(@Nonnull String location) {
3636
throw new IllegalArgumentException("Invalid S3 location uri " + location);
3737
}
3838
this.scheme = matcher.group(1);
39-
this.objectKeyWBucket = matcher.group(2);
39+
this.locationWithoutScheme = matcher.group(2);
4040
}
4141

4242
public static boolean isS3Location(String location) {
@@ -52,8 +52,8 @@ public boolean isChildOf(StorageLocation potentialParent) {
5252
if (potentialParent instanceof S3Location) {
5353
S3Location that = (S3Location) potentialParent;
5454
// Given that S3 and S3A are to be treated similarly, the parent check ignores the prefix
55-
String slashTerminatedObjectKey = ensureTrailingSlash(this.objectKeyWBucket);
56-
String slashTerminatedObjectKeyThat = ensureTrailingSlash(that.objectKeyWBucket);
55+
String slashTerminatedObjectKey = ensureTrailingSlash(this.locationWithoutScheme);
56+
String slashTerminatedObjectKeyThat = ensureTrailingSlash(that.locationWithoutScheme);
5757
return slashTerminatedObjectKey.startsWith(slashTerminatedObjectKeyThat);
5858
}
5959
return false;
@@ -63,7 +63,8 @@ public String getScheme() {
6363
return scheme;
6464
}
6565

66-
public String getObjectKeyWBucket() {
67-
return objectKeyWBucket;
66+
@Override
67+
public String withoutScheme() {
68+
return locationWithoutScheme;
6869
}
6970
}

polaris-core/src/test/java/org/apache/polaris/core/storage/aws/S3LocationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void testLocation(String scheme) {
3434
Assertions.assertThat(loc).isInstanceOf(S3Location.class);
3535
S3Location s3Loc = (S3Location) loc;
3636
Assertions.assertThat(s3Loc.getScheme()).isEqualTo(scheme);
37-
Assertions.assertThat(s3Loc.getObjectKeyWBucket()).isEqualTo("bucket/schema1/table1");
37+
Assertions.assertThat(s3Loc.withoutScheme()).isEqualTo("//bucket/schema1/table1");
3838
Assertions.assertThat(s3Loc.withoutScheme()).doesNotStartWith(scheme);
3939
Assertions.assertThat(scheme + ":" + s3Loc.withoutScheme()).isEqualTo(locInput);
4040
}

runtime/service/src/test/java/org/apache/polaris/service/quarkus/entity/CatalogEntityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ public void testInvalidAllowedLocationPrefixS3(String scheme) {
6868
.setStorageType(StorageConfigInfo.StorageTypeEnum.S3)
6969
.setAllowedLocations(List.of(storageLocation, scheme + "://externally-owned-bucket"))
7070
.build();
71-
CatalogProperties prop = new CatalogProperties(storageLocation);
71+
CatalogProperties props = new CatalogProperties(storageLocation);
7272
Catalog awsCatalog =
7373
PolarisCatalog.builder()
7474
.setType(Catalog.TypeEnum.INTERNAL)
7575
.setName("name")
76-
.setProperties(prop)
76+
.setProperties(props)
7777
.setStorageConfigInfo(awsStorageConfigModel)
7878
.build();
7979
Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(callContext, awsCatalog))

0 commit comments

Comments
 (0)