You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "roryqi (via GitHub)" <gi...@apache.org> on 2026/08/21 07:43:13 UTC
[PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
roryqi opened a new pull request, #12549:
URL: https://github.com/apache/gravitino/pull/12549
### What changes were proposed in this pull request?
Add the public Java API contracts for policy-on-tag:
1. Add `PolicyTagAssociation` and `PolicyTagSelector`.
2. Add policy-to-tag association operations to `PolicyOperations` and `TagOperations`.
3. Add `VIEW_POLICY` and `VIEW_TAG` privileges.
4. Add tests for tag-value selector matching and privilege binding scopes.
The new operation methods provide default implementations that throw
`UnsupportedOperationException`, keeping existing implementations source-compatible
until the implementation PRs override them.
### Why are the changes needed?
These APIs establish the public contracts required by the policy-on-tag governance
model and allow the implementation to be reviewed in smaller follow-up PRs.
Fix: #12548
Part of #12176.
### Does this PR introduce _any_ user-facing change?
Yes. It adds evolving Java APIs for policy-to-tag associations, tag-value selectors,
and policy/tag view privileges. This PR does not add runtime implementation behavior.
### How was this patch tested?
- `./gradlew spotlessApply`
- `./gradlew :api:test :clients:client-java:compileJava`
- `git diff --check`
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851130007
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
Can we support tag + multiple selectors + policy?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi merged PR #12549:
URL: https://github.com/apache/gravitino/pull/12549
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850629589
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
Should you specify the selector for the remove operation?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851684811
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
My point is that tag + one select + policy is uniquely identified as a tuple, am I right? So tag + select A + policy is different from tag + select B + policy. In your API, you only let user to specify tag + policy, so all the combinations will be deleted. If users they only want to delete tag + select A + policy, how do you achieve this?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3852374534
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
Also, the API contract rejects a second association for the same tag and policy by throwing PolicyAlreadyAssociatedException. I reused the existing exception and updated its Javadoc in b34d37f1f to cover tag associations. This is consistent with having one unique relation for each (tag_id, policy_id) pair.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3844269731
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.gravitino.policy;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its optional assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
+
+ /**
+ * @return The selector, or empty when the association matches by tag presence.
+ */
+ Optional<PolicySelector> selector();
Review Comment:
No. The selector belongs to a specific policy-to-tag association, not to the policy definition itself. The same policy can be associated with different tags using different selectors. To make this ownership explicit, I renamed `PolicySelector` to `PolicyAssociationSelector`. The concrete selector implementations are now `AllValuesSelector` and `TagValueSelector`.
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +117,64 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds or updates one policy association for a tag without a selector.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
Review Comment:
We no longer represent this behavior with a missing or null selector. Every policy-to-tag association has an explicit selector. `AllValuesSelector` is used for tag-presence matching and matches whenever the effective tag assignment exists, regardless of whether it has no value, one value, or multiple values. The two-argument `addPolicyForTag` overload delegates using `AllValuesSelector`, and `PolicyTagAssociation.selector()` is now non-optional.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3843030333
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.gravitino.policy;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its optional assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
+
+ /**
+ * @return The selector, or empty when the association matches by tag presence.
+ */
+ Optional<PolicySelector> selector();
Review Comment:
Is `PolicySelector` a part of policy?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851121237
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.gravitino.policy;
+
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its required assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
Review Comment:
PolicyTagAssociation describes the configured relation: tag() identifies the tag, and selector() identifies the matching value condition. If the caller wants to know which policies actually apply to a specific metadata object based on its effective tag assignments, it should use SupportsPolicies.listPolicies() or listPolicyInfos() on that metadata object. The object policy resolution evaluates the tag assignments against the selectors and returns only the matched policies.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850535446
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.gravitino.policy;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its optional assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
+
+ /**
+ * @return The selector, or empty when the association matches by tag presence.
+ */
+ Optional<PolicySelector> selector();
Review Comment:
No, it's stored in the association about policy and tag.
```
CREATE TABLE IF NOT EXISTS policy_tag_relation_meta (
id BIGSERIAL NOT NULL,
policy_id BIGINT NOT NULL,
tag_id BIGINT NOT NULL,
selector TEXT DEFAULT NULL,
audit_info TEXT NOT NULL,
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id),
UNIQUE (policy_id, tag_id, deleted_at)
);
```
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850845356
##########
api/src/main/java/org/apache/gravitino/policy/PolicyOperations.java:
##########
@@ -106,4 +106,27 @@ Policy alterPolicy(String name, PolicyChange... changes)
* @return True if the policy is deleted, false if the policy does not exist.
*/
boolean deletePolicy(String name);
+
+ /**
+ * Lists tag names directly associated with a policy.
+ *
+ * @param policyName The policy name.
+ * @return The directly associated tag names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listTagsForPolicy(String policyName) {
+ throw new UnsupportedOperationException("Listing tags for a policy is not supported");
+ }
+
+ /**
+ * Lists detailed tag associations for a policy.
+ *
+ * @param policyName The policy name.
+ * @return The tag associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listTagAssociationsForPolicy(String policyName) {
+ throw new UnsupportedOperationException(
+ "Listing tag associations for a policy is not supported");
Review Comment:
No. This API returns all direct policy-to-tag associations and does not evaluate selectors because there is no metadata object context. I clarified the Javadoc in b25ac7066.
##########
api/src/main/java/org/apache/gravitino/policy/PolicyOperations.java:
##########
@@ -106,4 +106,27 @@ Policy alterPolicy(String name, PolicyChange... changes)
* @return True if the policy is deleted, false if the policy does not exist.
*/
boolean deletePolicy(String name);
+
+ /**
+ * Lists tag names directly associated with a policy.
+ *
+ * @param policyName The policy name.
+ * @return The directly associated tag names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listTagsForPolicy(String policyName) {
+ throw new UnsupportedOperationException("Listing tags for a policy is not supported");
+ }
Review Comment:
Agreed. I removed listTagsForPolicy and the symmetric listPoliciesForTag. Callers now use the association APIs, which return PolicyTagAssociation entries including their selectors. Updated in b25ac7066.
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
No. Each policy-to-tag pair has at most one active association. The selector is an attribute of that relation, so tagName and policyName uniquely identify the association to remove.
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.gravitino.policy;
+
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its required assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
Review Comment:
No. This association has no metadata object context, so the returned Tag does not carry an assignment. The effective assignment is loaded separately when resolving policies for a specific object.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#issuecomment-5368589640
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|67.55% **`-0.01%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|66.2%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|49.24% **`+1.83%`**|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|authorization-ranger|4.38%|:red_circle:|
|aws|42.04%|:green_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|9.92%|:red_circle:|
|catalog-fileset|79.77%|:green_circle:|
|catalog-glue|68.95%|:green_circle:|
|catalog-hive|82.96%|:green_circle:|
|catalog-jdbc-common|45.7%|:green_circle:|
|catalog-jdbc-doris|82.44%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|59.18%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.86%|:green_circle:|
|catalog-lakehouse-paimon|84.23%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.58%|:green_circle:|
|common|52.39%|:green_circle:|
|core|83.57%|:green_circle:|
|filesystem-hadoop3|77.28%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|48.68%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|12.7%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.0%|:green_circle:|
|idp-basic|85.98%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|31.63%|:red_circle:|
|lance-rest-server|63.47%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|87.57%|:green_circle:|
|server-common|79.57%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|45.89%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|42.21%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|api|[Privilege.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/authorization/Privilege.java)|95.65%|:green_circle:|
||[TagValuePolicySelector.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/policy/TagValuePolicySelector.java)|73.33%|:green_circle:|
||[Privileges.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/authorization/Privileges.java)|63.99%|:green_circle:|
||[PolicyOperations.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/policy/PolicyOperations.java)|0.0%|:red_circle:|
||[PolicySelector.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/policy/PolicySelector.java)|0.0%|:red_circle:|
||[PolicyTagAssociation.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java)|0.0%|:red_circle:|
||[TagOperations.java](https://github.com/qqqttt123/gravitino/blob/118fc61afc76cf71dbd2d21c78666973719f352c/api/src/main/java/org/apache/gravitino/tag/TagOperations.java)|0.0%|:red_circle:|
</details>
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850543184
##########
api/src/main/java/org/apache/gravitino/policy/PolicyOperations.java:
##########
@@ -106,4 +106,27 @@ Policy alterPolicy(String name, PolicyChange... changes)
* @return True if the policy is deleted, false if the policy does not exist.
*/
boolean deletePolicy(String name);
+
+ /**
+ * Lists tag names directly associated with a policy.
+ *
+ * @param policyName The policy name.
+ * @return The directly associated tag names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listTagsForPolicy(String policyName) {
+ throw new UnsupportedOperationException("Listing tags for a policy is not supported");
+ }
+
+ /**
+ * Lists detailed tag associations for a policy.
+ *
+ * @param policyName The policy name.
+ * @return The tag associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listTagAssociationsForPolicy(String policyName) {
+ throw new UnsupportedOperationException(
+ "Listing tag associations for a policy is not supported");
Review Comment:
Will this returned tag be filtered out by the selector? If so, can you add the comments to clarify the behavior?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850496660
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.gravitino.policy;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its optional assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
+
+ /**
+ * @return The selector, or empty when the association matches by tag presence.
+ */
+ Optional<PolicySelector> selector();
Review Comment:
How do we store this select? Will it be stored with policy?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850584452
##########
api/src/main/java/org/apache/gravitino/policy/PolicyOperations.java:
##########
@@ -106,4 +106,27 @@ Policy alterPolicy(String name, PolicyChange... changes)
* @return True if the policy is deleted, false if the policy does not exist.
*/
boolean deletePolicy(String name);
+
+ /**
+ * Lists tag names directly associated with a policy.
+ *
+ * @param policyName The policy name.
+ * @return The directly associated tag names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listTagsForPolicy(String policyName) {
+ throw new UnsupportedOperationException("Listing tags for a policy is not supported");
+ }
Review Comment:
My feeling is that this interface is not so useful. It is just the tag name, we cannot differentiate what the actual tag assignment is and what is the selector enforced in the policy.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851818263
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
That is not the intended identity. The unique key is (tag_id, policy_id), and each relation contains exactly one selector. The selector is a mutable predicate of the relation, not part of its key. If a condition needs multiple values or clauses, one composite selector should express the AND/OR relationship explicitly. Therefore, selector A and selector B are not separate relations to delete: changing the condition replaces the selector, while remove deletes the unique policy-to-tag relation. My concern with allowing multiple selectors is that their relationship would be implicit and ambiguous: it would be unclear whether they are combined with AND or OR, and the lifecycle would become more complex. Is there a concrete use case that cannot be represented by one selector with explicit AND/OR semantics?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851066375
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.gravitino.policy;
+
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its required assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
Review Comment:
So, how do we know which tag with value is assoicated with the policy?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851143256
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.gravitino.policy;
+
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its required assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
Review Comment:
I will add comments for the interface `supportsPolicy`.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851439130
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It matches by tag
+ * presence regardless of assignment values and does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is not supported");
+ }
Review Comment:
We can support multi-value matching, but a policy-to-tag association should still contain only one selector. If multiple values or conditions are required, that selector should represent them as a single composite condition with explicit matching semantics, rather than attaching multiple selectors to the same association. This keeps the policy-to-tag relation unique and does not change the remove API. The selector interface is extensible, so this can be added as a new selector type. Phase 1 supports ALL_VALUES and the single-value TAG_VALUE; a multi-value selector can be added separately.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3843035013
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +117,64 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds or updates one policy association for a tag without a selector.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws UnsupportedOperationException If adding policy-to-tag associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not supported");
+ }
Review Comment:
What is the behavior if we don't specify the `PolicySelector`?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12548] feat(api): add policy-on-tag APIs [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3850658084
##########
api/src/main/java/org/apache/gravitino/policy/PolicyTagAssociation.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.gravitino.policy;
+
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.tag.Tag;
+
+/** A policy-to-tag association and its required assignment selector. */
+@Evolving
+public interface PolicyTagAssociation {
+
+ /**
+ * @return The associated policy.
+ */
+ Policy policy();
+
+ /**
+ * @return The associated tag.
+ */
+ Tag tag();
Review Comment:
Does this tag here have assignments or not when returned?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org