Re: [PR] core: Standardize Path Lookup Key for `PolarisResolutionManifest.getResolutionPath` [polaris]
adutra commented on code in PR #3940:
URL: https://github.com/apache/polaris/pull/3940#discussion_r2890924295
##
runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##
@@ -384,8 +387,7 @@ private PolarisResolutionManifest
authorizeGrantOnCatalogRoleToPrincipalRoleOper
String principalRoleName) {
PolarisResolutionManifest resolutionManifest =
newResolutionManifest(catalogName);
resolutionManifest.addPath(
-new ResolverPath(List.of(catalogRoleName),
PolarisEntityType.CATALOG_ROLE),
-catalogRoleName);
+new ResolverPath(List.of(catalogRoleName),
PolarisEntityType.CATALOG_ROLE));
Review Comment:
I am observing the following similarity:
```java
private record ResolverPathKey(List entityNames, PolarisEntityType
entityType) {}
public record ResolverPath (List entityNames, PolarisEntityType
lastEntityType, boolean optional) {}
```
Wouldn't it be better to define these records by composition? E.g.:
```java
public record ResolverPathKey(List entityNames, PolarisEntityType
entityType) {}
public record ResolverPath(ResolverPathKey key, boolean optional) {}
##
polaris-core/src/main/java/org/apache/polaris/core/persistence/resolver/PolarisResolutionManifestCatalogView.java:
##
@@ -39,13 +40,15 @@ public interface PolarisResolutionManifestCatalogView {
.orElse(null);
}
- PolarisResolvedPathWrapper getResolvedPath(Object key);
+ PolarisResolvedPathWrapper getResolvedPath(
+ List entityNames, PolarisEntityType entityType);
Review Comment:
Would it be simpler to expose ResolverPathKey publicly and transform these
methods as follows:
```java
PolarisResolvedPathWrapper getResolvedPath(ResolvedPathKey key);
PolarisResolvedPathWrapper getResolvedPath(
ResolvedPathKey key, PolarisEntitySubType subType);
PolarisResolvedPathWrapper getPassthroughResolvedPath(
ResolvedPathKey key);
PolarisResolvedPathWrapper getPassthroughResolvedPath(
ResolvedPathKey key, PolarisEntitySubType subType);
```
Then `ResolvedPathKey` could expose some factory methods to quickly create
keys from different types of entities. E.g.
```java
resolvedEntityView.getResolvedPath(
PolarisCatalogHelpers.tableIdentifierToList(tableIdentifier),
PolarisEntityType.TABLE_LIKE,
PolarisEntitySubType.ICEBERG_TABLE);
```
Becomes:
```java
resolvedEntityView.getResolvedPath(
ResolvedPathKey.ofTable(tableIdentifier),
PolarisEntitySubType.ICEBERG_TABLE);
```
Just a suggestion :-)
--
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]
Re: [PR] core: Standardize Path Lookup Key for `PolarisResolutionManifest.getResolutionPath` [polaris]
Copilot commented on code in PR #3940:
URL: https://github.com/apache/polaris/pull/3940#discussion_r2890914903
##
polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisResolutionManifestLookUpKeyTest.java:
##
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
+import org.apache.polaris.core.auth.PolarisPrincipal;
+import org.apache.polaris.core.context.RealmContext;
+import org.apache.polaris.core.entity.PolarisEntityType;
+import org.apache.polaris.core.persistence.resolver.PolarisResolutionManifest;
+import org.apache.polaris.core.persistence.resolver.Resolver;
+import org.apache.polaris.core.persistence.resolver.ResolverFactory;
+import org.apache.polaris.core.persistence.resolver.ResolverPath;
+import org.apache.polaris.core.persistence.resolver.ResolverStatus;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+public class PolarisResolutionManifestLookUpKeyTest {
Review Comment:
The test class name uses mixed casing "LookUp"; in this codebase "Lookup" is
used elsewhere (e.g., RealmConfigImplTest.legacyLookup). Renaming the class
(and file) to `PolarisResolutionManifestLookupKeyTest` would improve
consistency and discoverability.
```suggestion
public class PolarisResolutionManifestLookupKeyTest {
```
--
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]
