eric-maynard commented on code in PR #1686:
URL: https://github.com/apache/polaris/pull/1686#discussion_r2158089905
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java:
##########
@@ -622,6 +632,64 @@ public boolean hasChildren(
}
}
+ private int loadVersion() {
+ PreparedQuery query = QueryGenerator.generateVersionQuery();
+ try {
+ List<SchemaVersion> schemaVersion =
+ datasourceOperations.executeSelect(query, new SchemaVersion());
+ if (schemaVersion == null || schemaVersion.size() != 1) {
+ throw new RuntimeException("Failed to retrieve schema version");
+ }
+ return schemaVersion.getFirst().getValue();
+ } catch (SQLException e) {
+ LOGGER.error("Failed to load schema version due to {}", e.getMessage(),
e);
+ throw new RuntimeException("Failed to retrieve schema version", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public <T extends PolarisEntity & LocationBasedEntity>
+ Optional<Optional<String>> hasOverlappingSiblings(
+ @Nonnull PolarisCallContext callContext, T entity) {
+ if (this.version < 2) {
+ return Optional.empty();
+ }
+ if (entity.getBaseLocation().chars().filter(ch -> ch == '/').count()
+ > MAX_LOCATION_COMPONENTS) {
+ return Optional.empty();
+ }
+
+ PreparedQuery query =
+ QueryGenerator.generateOverlapQuery(
+ realmId, entity.getParentId(), entity.getBaseLocation());
+ try {
+ var results = datasourceOperations.executeSelect(query, new
ModelEntity());
+ if (!results.isEmpty()) {
+ StorageLocation entityLocation =
StorageLocation.of(entity.getBaseLocation());
+ for (PolarisBaseEntity result : results) {
+ StorageLocation potentialSiblingLocation =
+ StorageLocation.of(((LocationBasedEntity)
result).getBaseLocation());
+ if (entityLocation.isChildOf(potentialSiblingLocation)
+ || potentialSiblingLocation.isChildOf(entityLocation)) {
+ return
Optional.of(Optional.of(potentialSiblingLocation.toString()));
Review Comment:
So right now we don't support s3a and if we did the current logic would miss
the s3/s3a check. We need something like `AzureLocation` for the other clouds
to support that. But the goal here is just to optimize the current logic
--
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]