This is an automated email from the ASF dual-hosted git repository.

snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 880dfa1e0 Remove duplicate code in `PolicyCatalog` (#3781)
880dfa1e0 is described below

commit 880dfa1e0ed9547095372c1510055c48b547d52c
Author: Robert Stupp <[email protected]>
AuthorDate: Wed Feb 18 11:14:27 2026 +0100

    Remove duplicate code in `PolicyCatalog` (#3781)
---
 .../service/catalog/policy/PolicyCatalog.java      | 33 ++--------------------
 .../service/catalog/policy/PolicyCatalogUtils.java |  4 +--
 2 files changed, 4 insertions(+), 33 deletions(-)

diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalog.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalog.java
index 9b2f7c8a6..2ceafab5a 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalog.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalog.java
@@ -23,7 +23,6 @@ import static 
org.apache.polaris.core.persistence.dao.entity.BaseResult.ReturnSt
 import static 
org.apache.polaris.service.types.PolicyAttachmentTarget.TypeEnum.CATALOG;
 
 import com.google.common.base.Strings;
-import jakarta.annotation.Nonnull;
 import jakarta.annotation.Nullable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -299,7 +298,7 @@ public class PolicyCatalog {
     var policyCatalogPath = 
PolarisEntity.toCoreList(resolvedPolicyPath.getRawParentPath());
     var policyEntity = PolicyEntity.of(resolvedPolicyPath.getRawLeafEntity());
 
-    var resolvedTargetPath = getResolvedPathWrapper(target);
+    var resolvedTargetPath = 
PolicyCatalogUtils.getResolvedPathWrapper(resolvedEntityView, target);
     var targetCatalogPath = 
PolarisEntity.toCoreList(resolvedTargetPath.getRawParentPath());
     var targetEntity = resolvedTargetPath.getRawLeafEntity();
 
@@ -335,7 +334,7 @@ public class PolicyCatalog {
     var policyCatalogPath = 
PolarisEntity.toCoreList(resolvedPolicyPath.getRawParentPath());
     var policyEntity = PolicyEntity.of(resolvedPolicyPath.getRawLeafEntity());
 
-    var resolvedTargetPath = getResolvedPathWrapper(target);
+    var resolvedTargetPath = 
PolicyCatalogUtils.getResolvedPathWrapper(resolvedEntityView, target);
     var targetCatalogPath = 
PolarisEntity.toCoreList(resolvedTargetPath.getRawParentPath());
     var targetEntity = resolvedTargetPath.getRawLeafEntity();
 
@@ -492,34 +491,6 @@ public class PolicyCatalog {
     return resolvedEntities;
   }
 
-  private PolarisResolvedPathWrapper getResolvedPathWrapper(
-      @Nonnull PolicyAttachmentTarget target) {
-    return switch (target.getType()) {
-      // get the current catalog entity, since policy cannot apply across 
catalog at this moment
-      case CATALOG -> resolvedEntityView.getResolvedReferenceCatalogEntity();
-      case NAMESPACE -> {
-        var namespace = Namespace.of(target.getPath().toArray(new String[0]));
-        var resolvedTargetEntity = 
resolvedEntityView.getResolvedPath(namespace);
-        if (resolvedTargetEntity == null) {
-          throw new NoSuchNamespaceException("Namespace does not exist: %s", 
namespace);
-        }
-        yield resolvedTargetEntity;
-      }
-      case TABLE_LIKE -> {
-        var tableIdentifier = TableIdentifier.of(target.getPath().toArray(new 
String[0]));
-        // only Iceberg tables are supported
-        var resolvedTableEntity =
-            resolvedEntityView.getResolvedPath(
-                tableIdentifier, PolarisEntityType.TABLE_LIKE, 
PolarisEntitySubType.ICEBERG_TABLE);
-        if (resolvedTableEntity == null) {
-          throw new NoSuchTableException("Iceberg Table does not exist: %s", 
tableIdentifier);
-        }
-        yield resolvedTableEntity;
-      }
-      default -> throw new IllegalArgumentException("Unsupported target type: 
" + target.getType());
-    };
-  }
-
   private static Policy constructPolicy(PolicyEntity policyEntity) {
     return Policy.builder()
         .setPolicyType(policyEntity.getPolicyType().getName())
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogUtils.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogUtils.java
index 42364a3e4..173ddf50e 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogUtils.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogUtils.java
@@ -26,13 +26,13 @@ import org.apache.iceberg.exceptions.NoSuchTableException;
 import org.apache.polaris.core.entity.PolarisEntitySubType;
 import org.apache.polaris.core.entity.PolarisEntityType;
 import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper;
-import org.apache.polaris.core.persistence.resolver.PolarisResolutionManifest;
+import 
org.apache.polaris.core.persistence.resolver.PolarisResolutionManifestCatalogView;
 import org.apache.polaris.service.types.PolicyAttachmentTarget;
 
 public class PolicyCatalogUtils {
 
   public static PolarisResolvedPathWrapper getResolvedPathWrapper(
-      @Nonnull PolarisResolutionManifest resolutionManifest,
+      @Nonnull PolarisResolutionManifestCatalogView resolutionManifest,
       @Nonnull PolicyAttachmentTarget target) {
     return switch (target.getType()) {
       // get the current catalog entity, since policy cannot apply across 
catalog at this moment

Reply via email to