in polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java [138:194]
public static Optional<PolarisStorageConfigurationInfo> forEntityPath(
PolarisDiagnostics diagnostics, List<PolarisEntity> entityPath) {
return findStorageInfoFromHierarchy(entityPath)
.map(
storageInfo ->
deserialize(
diagnostics,
storageInfo
.getInternalPropertiesAsMap()
.get(PolarisEntityConstants.getStorageConfigInfoPropertyName())))
.map(
configInfo -> {
List<PolarisEntity> entityPathReversed = new ArrayList<>(entityPath);
Collections.reverse(entityPathReversed);
String baseLocation =
entityPathReversed.stream()
.flatMap(
e ->
Optional.ofNullable(
e.getPropertiesAsMap()
.get(PolarisEntityConstants.ENTITY_BASE_LOCATION))
.stream())
.findFirst()
.orElse(null);
CatalogEntity catalog = CatalogEntity.of(entityPath.get(0));
boolean allowEscape =
CallContext.getCurrentContext()
.getPolarisCallContext()
.getConfigurationStore()
.getConfiguration(
CallContext.getCurrentContext().getPolarisCallContext(),
catalog,
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION);
if (!allowEscape
&& catalog.getCatalogType() != Catalog.TypeEnum.EXTERNAL
&& baseLocation != null) {
LOGGER.debug(
"Not allowing unstructured table location for entity: {}",
entityPathReversed.get(0).getName());
return new StorageConfigurationOverride(configInfo, List.of(baseLocation));
} else {
LOGGER.debug(
"Allowing unstructured table location for entity: {}",
entityPathReversed.get(0).getName());
List<String> locs =
userSpecifiedWriteLocations(entityPathReversed.get(0).getPropertiesAsMap());
return new StorageConfigurationOverride(
configInfo,
ImmutableList.<String>builder()
.addAll(configInfo.getAllowedLocations())
.addAll(locs)
.build());
}
});
}