eric-maynard commented on code in PR #1686: URL: https://github.com/apache/polaris/pull/1686#discussion_r2122645159
########## extension/persistence/relational-jdbc/src/main/java/org/apache/polaris/extension/persistence/relational/jdbc/JdbcBasePersistenceImpl.java: ########## @@ -556,6 +563,51 @@ public boolean hasChildren( } } + private int loadVersion() { + String query = 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 Optional<Optional<String>> hasOverlappingSiblings( + @Nonnull PolarisCallContext callContext, long parentId, String location) { + if (this.version < 2) { + return Optional.empty(); + } + if (location.chars().filter(ch -> ch == '/').count() > MAX_LOCATION_COMPONENTS) { + return Optional.empty(); + } + + String query = QueryGenerator.generateOverlapQuery(realmId, parentId, location); + try { + var results = datasourceOperations.executeSelect(query, new ModelEntity()); + if (results.isEmpty()) { Review Comment: Then the check will pass; if you have a mixed persistence like this, you should not enable `OPTIMIZED_SIBLING_CHECK`. It's disabled by default. ########## extension/persistence/relational-jdbc/src/main/java/org/apache/polaris/extension/persistence/relational/jdbc/JdbcBasePersistenceImpl.java: ########## @@ -556,6 +563,51 @@ public boolean hasChildren( } } + private int loadVersion() { + String query = 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 Optional<Optional<String>> hasOverlappingSiblings( + @Nonnull PolarisCallContext callContext, long parentId, String location) { + if (this.version < 2) { + return Optional.empty(); + } + if (location.chars().filter(ch -> ch == '/').count() > MAX_LOCATION_COMPONENTS) { + return Optional.empty(); + } + + String query = QueryGenerator.generateOverlapQuery(realmId, parentId, location); + try { + var results = datasourceOperations.executeSelect(query, new ModelEntity()); + if (results.isEmpty()) { Review Comment: Then the check will pass; if you have a persistence in a weird state like this, you should not enable `OPTIMIZED_SIBLING_CHECK`. It's disabled by default. -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org