dennishuo commented on code in PR #321:
URL: https://github.com/apache/polaris/pull/321#discussion_r1777732986


##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -1873,6 +1878,51 @@ private boolean sendNotificationForTableLike(
     if (notificationType == NotificationType.DROP) {
       return dropTableLike(PolarisEntitySubType.TABLE, tableIdentifier, 
Map.of(), false /* purge */)
           .isSuccess();
+    } else if (notificationType == NotificationType.VALIDATE) {
+      // In this mode we don't want to make any mutations, so we won't 
auto-create non-existing
+      // parent namespaces. This means when we want to validate 
allowedLocations for the proposed
+      // table metadata location, we must independently find the deepest 
non-null parent namespace
+      // of the TableIdentifier, which may even be the base CatalogEntity if 
no parent namespaces
+      // actually exist yet. We can then extract the right StorageInfo entity 
via a normal call
+      // to findStorageInfoFromHierarchy.
+      PolarisResolvedPathWrapper resolvedStorageEntity = null;
+      Optional<PolarisEntity> storageInfoEntity = Optional.empty();
+      for (int i = tableIdentifier.namespace().length(); i >= 0; i--) {
+        Namespace nsLevel =
+            Namespace.of(
+                Arrays.stream(tableIdentifier.namespace().levels())
+                    .limit(i)
+                    .toArray(String[]::new));
+        resolvedStorageEntity = resolvedEntityView.getResolvedPath(nsLevel);
+        if (resolvedStorageEntity != null) {
+          storageInfoEntity = 
findStorageInfoFromHierarchy(resolvedStorageEntity);
+          break;
+        }
+      }
+
+      if (resolvedStorageEntity == null || storageInfoEntity.isEmpty()) {
+        throw new org.apache.iceberg.exceptions.BadRequestException(
+            "Failed to find StorageInfo entity for TableIdentifier %s", 
tableIdentifier);
+      }
+
+      // Validate location against the resolvedStorageEntity
+      String metadataLocation =

Review Comment:
   I described some of the options in the rest spec description, but in a 
nutshell it can be either a parent directory or a prospective full filename, 
and the behavior is simply for the validation to ensure that whatever path is 
specified conforms to the ALLOWED_LOCATIONS  of the storage config.



-- 
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]

Reply via email to