RussellSpitzer commented on code in PR #193:
URL: https://github.com/apache/polaris/pull/193#discussion_r1730625443
##########
polaris-core/src/main/java/io/polaris/core/storage/PolarisStorageConfigurationInfo.java:
##########
@@ -171,11 +177,38 @@ public static Optional<PolarisStorageConfigurationInfo>
forEntityPath(
LOGGER.debug(
"Allowing unstructured table location for entity: {}",
entityPathReversed.get(0).getName());
- return configInfo;
+ return
userSpecifiedWriteLocations(entityPathReversed.get(0).getPropertiesAsMap())
+ .map(
+ locs ->
+ (PolarisStorageConfigurationInfo)
+ new StorageConfigurationOverride(
+ configInfo,
+ ImmutableList.<String>builder()
+
.addAll(configInfo.getAllowedLocations())
+ .addAll(locs)
+ .build()))
+ .orElse(configInfo);
}
});
}
+ private static Optional<List<String>> userSpecifiedWriteLocations(
+ Map<String, String> properties) {
+ return Optional.ofNullable(properties)
+ .flatMap(
+ p ->
+ Stream.of(
+
p.get(TableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY),
+
p.get(TableLikeEntity.USER_SPECIFIED_WRITE_METADATA_LOCATION_KEY))
+ .filter(Objects::nonNull)
+ .collect(
+ Collector.<String, List<String>,
Optional<List<String>>>of(
+ ArrayList::new,
+ List::add,
+ (l, r) ->
ImmutableList.<String>builder().addAll(l).addAll(r).build(),
+ l -> l.isEmpty() ? Optional.empty() :
Optional.of(l))));
Review Comment:
Check Optional.ofNullable to simplify this ternary
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]