eric-maynard commented on code in PR #1686:
URL: https://github.com/apache/polaris/pull/1686#discussion_r2116256024
##########
extension/persistence/relational-jdbc/src/main/java/org/apache/polaris/extension/persistence/relational/jdbc/QueryGenerator.java:
##########
@@ -190,6 +210,30 @@ public static String generateWhereClause(@Nonnull
Map<String, Object> whereClaus
return !whereConditionsString.isEmpty() ? (" WHERE " +
whereConditionsString) : "";
}
+ @VisibleForTesting
+ public static String generateVersionQuery() {
+ return "SELECT version_value FROM POLARIS_SCHEMA.VERSION";
+ }
+
+ @VisibleForTesting
+ public static String generateOverlapQuery(String realmId, long parentId,
String location) {
+ String[] components = location.split("/");
+ StringBuilder locationClauseBuilder = new StringBuilder();
+ StringBuilder pathBuilder = new StringBuilder();
+ for (String component : components) {
+ pathBuilder.append(component).append("/");
+ locationClauseBuilder.append(String.format(" OR location = '%s'",
pathBuilder));
+ }
+ locationClauseBuilder.append(String.format(" OR location LIKE '%s%%'",
location));
+ String query = "SELECT " + String.join(", ", new
ModelEntity().toMap().keySet());
+
+ // TODO harden against realmId in this method and others
+ return query
+ + String.format(
+ " FROM POLARIS_SCHEMA.entities WHERE realm_id = '%s' AND parent_id
= %d AND (1 = 2%s)",
+ realmId, parentId, locationClauseBuilder);
+ }
Review Comment:
We don't need to load the table if all we want to do is the sibling check,
yeah. I select only the location for logging purposes
--
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]