You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "yunchipang (via GitHub)" <gi...@apache.org> on 2025/06/25 19:37:16 UTC

[PR] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

yunchipang opened a new pull request, #7476:
URL: https://github.com/apache/gravitino/pull/7476

   <!--
   1. Title: [#<issue>] <type>(<scope>): <subject>
      Examples:
        - "[#123] feat(operator): support xxx"
        - "[#233] fix: check null before access result in xxx"
        - "[MINOR] refactor: fix typo in variable name"
        - "[MINOR] docs: fix typo in README"
        - "[#255] test: fix flaky test NameOfTheTest"
      Reference: https://www.conventionalcommits.org/en/v1.0.0/
   2. If the PR is unfinished, please mark this PR as draft.
   -->
   
   ### What changes were proposed in this pull request?
   
   Introduced a new `listMetadataObjectsForTags` API which lists an array of metadata objects with a list of tags as query param.
   
   ### Why are the changes needed?
   
   To avoid iteratively calling `tag.associatedObjects().objects()` when listing metadata objects for a group a tags.
   Fix: #7454
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, new REST API.
   
   ### How was this patch tested?
   
   tests added.
   


-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#issuecomment-3072218544

   Could you add new event to https://github.com/apache/gravitino/blob/f1395433f228b45df465ddc7db71c48505a74816/docs/gravitino-server-config.md?plain=1#L165 ?


-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2250301720


##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -89,4 +90,13 @@ Tag alterTag(String name, TagChange... changes)
    * @return True if the tag is deleted, false if the tag does not exist.
    */
   boolean deleteTag(String name);
+
+  /**
+   * List all metadata objects associated with the specified tags.
+   *
+   * @param tagNames Array of tag names to query for associated objects.
+   * @return Array of metadata objects associated with the specified tags.
+   * @throws NoSuchTagException If any of the specified tags do not exist.
+   */
+  MetadataObject[] listMetadataObjectsForTags(String[] tagNames) throws NoSuchTagException;

Review Comment:
   How do you differentiate which metadata objects associate to which tag based on the returned value?



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2201339277


##########
docs/manage-tags-in-gravitino.md:
##########
@@ -35,7 +36,7 @@ the future versions.
 4. Same tag can be associated to both parent and child metadata objects. When you list the
    associated tags of a child metadata object, this tag will be included twice in the result
    list with different `inherited` values.
-:::
+   :::

Review Comment:
   fixed! sorry it was auto-made by prettier plugin. will be more careful next time.



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2212066881


##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -226,6 +227,41 @@ public MetadataObject[] listMetadataObjectsForTag(String metalake, String name)
         });
   }
 
+  public MetadataObject[] listMetadataObjectsForTags(String metalake, String[] names)
+      throws NoSuchTagException {
+    if (names == null || names.length == 0) {
+      return new MetadataObject[0];
+    }
+    NameIdentifier[] tagIds =
+        Arrays.stream(names)
+            .map(name -> NameIdentifierUtil.ofTag(metalake, name))
+            .toArray(NameIdentifier[]::new);
+    return TreeLockUtils.doWithTreeLock(
+        NameIdentifier.of(metalake),

Review Comment:
   Why do we need to lock the entire metalake? I believe we only need to lock the parent of tag, please refer to `listMetadataObjectsForTag`



##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -248,6 +248,50 @@ public Response listMetadataObjectsForTag(
     }
   }
 
+  private String[] parseTagsParameter(String tagsParam) {
+    if (tagsParam == null || tagsParam.trim().isEmpty()) {
+      throw new IllegalArgumentException("Tags parameter cannot be null or empty");
+    }
+
+    return Arrays.stream(tagsParam.split(","))
+        .map(String::trim)
+        .filter(tag -> !tag.isEmpty())
+        .toArray(String[]::new);
+  }
+
+  @GET
+  @Path("objects")
+  @Produces("application/vnd.gravitino.v1+json")
+  @Timed(name = "list-objects-for-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+  @ResponseMetered(name = "list-objects-for-tags", absolute = true)
+  public Response listMetadataObjectsForTags(
+      @PathParam("metalake") String metalake, @QueryParam("tags") String tagsParam) {
+    LOG.info("Received list objects for tags: {} under metalake: {}", tagsParam, metalake);
+
+    try {
+      return Utils.doAs(
+          httpRequest,
+          () -> {
+            String[] tagNames = parseTagsParameter(tagsParam);
+
+            MetadataObject[] objects = tagDispatcher.listMetadataObjectsForTags(metalake, tagNames);
+            objects = objects == null ? new MetadataObject[0] : objects;

Review Comment:
   When will `objects` be null?  I suggest you add the check in `listMetadataObjectsForTags` instead of putting it here.



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2250302300


##########
clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java:
##########
@@ -545,6 +546,28 @@ public boolean deleteTag(String name) {
     return resp.dropped();
   }
 
+  /**
+   * List all metadata objects associated with the specified tags.
+   *
+   * @param tagNames Array of tag names to query for associated objects.
+   * @return Array of metadata objects associated with the specified tags.
+   * @throws NoSuchTagException If any of the specified tags do not exist.
+   */
+  @Override
+  public MetadataObject[] listMetadataObjectsForTags(String[] tagNames) throws NoSuchTagException {
+    String tagsParam = String.join(",", tagNames);

Review Comment:
   If the tag name contains ",", then using "," to separate will have an issue.



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2206137991


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   Maybe we could create a separate issue to track the multi-identifier , let's go ahead



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#issuecomment-3125103503

   Sorry for the late response, I will review it soon.


-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang closed pull request #7476: [#7454] feat(tag): add list metadata objects for tags API
URL: https://github.com/apache/gravitino/pull/7476


-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2203742316


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   It's a little odd to use the first tag as the identifier.



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2188865789


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsFailureEvent.java:
##########


Review Comment:
   @FANNG1 could you plz help to review this part when you have time? thx!



##########
docs/open-api/openapi.yaml:
##########
@@ -77,6 +77,9 @@ paths:
   /metalakes/{metalake}/tags/{tag}/objects:
     $ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D~1objects"
 
+  /metalakes/{metalake}/tags/objects:

Review Comment:
   I realize that this request path may conflict with getting a tag? We may need to define a new path.
   
   The following are two solutions that come to my mind:
   1. Treat `objects` as a reserved tag name, which may break compatibility. (If the user already has a tag named `objects`, it cannot be retrieved anymore)
   2. using `GET /metalakes/{metalake}/objects?tags=tag1,tag2`
   
   I prefer the solution 2, WDYT?



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2206537120


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsPreEvent.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents a pre-event for listing metadata objects associated with multiple tags. */
+@DeveloperApi
+public class ListMetadataObjectsForTagsPreEvent extends TagPreEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs a new ListMetadataObjectsForTagsPreEvent instance.
+   *
+   * @param user The user performing the operation.
+   * @param metalake The name of the Metalake environment.
+   * @param tagNames The names of the tags.
+   */
+  public ListMetadataObjectsForTagsPreEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier
+    this.tagNames = tagNames;
+  }
+
+  /**
+   * Returns the tag names.
+   *
+   * @return the tag names.
+   */
+  public String[] getTagNames() {

Review Comment:
   getTagNames -> tagNames



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2205986659


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   @FANNG1 @mchades since `TagEvent` was designed to handle single tag identifier, the approach that requires the least code to be changed I can see now is to build a multi-tag identifier, for example:
   ```suggestion
     super(user, createTagListIdentifier(metalake, tagNames));
   ```
   
   and in some common utils dir,
   ```
   private static NameIdentifier createTagListIdentifier(String metalake, String[] tagNames) {
     String[] sortedTags = Arrays.stream(tagNames).sorted().toArray(String[]::new);
     String compositeTag = String.join(",", sortedTags);
     return NameIdentifierUtil.ofTag(metalake, compositeTag);
   }
   ```
   Pros: represents all tags involved, no breaking change to `TagEvent`
   Cons: long tags list may exceed identifier limits?
   
   If this does not look good for now, how about I go ahead and open an issue for future improvements on this?



##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   @FANNG1 @mchades since `TagEvent` was designed to handle single tag identifier, the approach that requires the least code to be changed I can see now is to build a multi-tag identifier, for example:
   ```suggestion
       super(user, createTagListIdentifier(metalake, tagNames));
   ```
   
   and in some common utils dir,
   ```
   private static NameIdentifier createTagListIdentifier(String metalake, String[] tagNames) {
     String[] sortedTags = Arrays.stream(tagNames).sorted().toArray(String[]::new);
     String compositeTag = String.join(",", sortedTags);
     return NameIdentifierUtil.ofTag(metalake, compositeTag);
   }
   ```
   Pros: represents all tags involved, no breaking change to `TagEvent`
   Cons: long tags list may exceed identifier limits?
   
   If this does not look good for now, how about I go ahead and open an issue for future improvements on 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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2305869824


##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -89,4 +90,13 @@ Tag alterTag(String name, TagChange... changes)
    * @return True if the tag is deleted, false if the tag does not exist.
    */
   boolean deleteTag(String name);
+
+  /**
+   * List all metadata objects associated with the specified tags.
+   *
+   * @param tagNames Array of tag names to query for associated objects.
+   * @return Array of metadata objects associated with the specified tags.
+   * @throws NoSuchTagException If any of the specified tags do not exist.
+   */
+  MetadataObject[] listMetadataObjectsForTags(String[] tagNames) throws NoSuchTagException;

Review Comment:
   thanks for the review! no I was not intended to differentiate tags based on metadata objects. is that a need?



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2379843255


##########
clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java:
##########
@@ -545,6 +546,28 @@ public boolean deleteTag(String name) {
     return resp.dropped();
   }
 
+  /**
+   * List all metadata objects associated with the specified tags.
+   *
+   * @param tagNames Array of tag names to query for associated objects.
+   * @return Array of metadata objects associated with the specified tags.
+   * @throws NoSuchTagException If any of the specified tags do not exist.
+   */
+  @Override
+  public MetadataObject[] listMetadataObjectsForTags(String[] tagNames) throws NoSuchTagException {
+    String tagsParam = String.join(",", tagNames);

Review Comment:
   implementation is updated, now perform as follows:
   1. client input: ["complex,tag1", "tag2"]
   2. client encoding: ["complex%2Ctag1", "tag2"]
   3. HTTP query param: "complex%2Ctag1,tag2"
   4. server split: ["complex%2Ctag1", "tag2"]
   5. server decoding: ["complex,tag1", "tag2"]



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2203748669


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   So, what's your suggestion for this change?



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2305902917


##########
clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java:
##########
@@ -545,6 +546,28 @@ public boolean deleteTag(String name) {
     return resp.dropped();
   }
 
+  /**
+   * List all metadata objects associated with the specified tags.
+   *
+   * @param tagNames Array of tag names to query for associated objects.
+   * @return Array of metadata objects associated with the specified tags.
+   * @throws NoSuchTagException If any of the specified tags do not exist.
+   */
+  @Override
+  public MetadataObject[] listMetadataObjectsForTags(String[] tagNames) throws NoSuchTagException {
+    String tagsParam = String.join(",", tagNames);

Review Comment:
   good point. how about encoding each tag individually before joining with commas? wdyt



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2200592093


##########
docs/manage-tags-in-gravitino.md:
##########
@@ -35,7 +36,7 @@ the future versions.
 4. Same tag can be associated to both parent and child metadata objects. When you list the
    associated tags of a child metadata object, this tag will be included twice in the result
    list with different `inherited` values.
-:::
+   :::

Review Comment:
   please remove the indent



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2213974085


##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -248,6 +248,50 @@ public Response listMetadataObjectsForTag(
     }
   }
 
+  private String[] parseTagsParameter(String tagsParam) {
+    if (tagsParam == null || tagsParam.trim().isEmpty()) {
+      throw new IllegalArgumentException("Tags parameter cannot be null or empty");
+    }
+
+    return Arrays.stream(tagsParam.split(","))
+        .map(String::trim)
+        .filter(tag -> !tag.isEmpty())
+        .toArray(String[]::new);
+  }
+
+  @GET
+  @Path("objects")
+  @Produces("application/vnd.gravitino.v1+json")
+  @Timed(name = "list-objects-for-tags." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+  @ResponseMetered(name = "list-objects-for-tags", absolute = true)
+  public Response listMetadataObjectsForTags(
+      @PathParam("metalake") String metalake, @QueryParam("tags") String tagsParam) {
+    LOG.info("Received list objects for tags: {} under metalake: {}", tagsParam, metalake);
+
+    try {
+      return Utils.doAs(
+          httpRequest,
+          () -> {
+            String[] tagNames = parseTagsParameter(tagsParam);
+
+            MetadataObject[] objects = tagDispatcher.listMetadataObjectsForTags(metalake, tagNames);
+            objects = objects == null ? new MetadataObject[0] : objects;

Review Comment:
   oops. I was following what `listMetadataObjectsForTag` did:
   https://github.com/apache/gravitino/blob/58e0a2f331149ee5aefff844cd44145443423cd1/server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java#L224-L233 
   after looking thru the code, I believe `tagDispatcher.listMetadataObjectsForTag()` never returns null, I am removing the null check for `objects` for both `listMetadataObjectsForTag` and `listMetadataObjectsForTags` then. thank you for pointing this out!



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2203742660


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier
+    this.tagNames = tagNames;
+  }
+
+  /**
+   * Returns the tag names.
+   *
+   * @return the tag names.
+   */
+  public String[] getTagNames() {

Review Comment:
   getTagNames -> tagNames



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2188895445


##########
docs/open-api/openapi.yaml:
##########
@@ -77,6 +77,9 @@ paths:
   /metalakes/{metalake}/tags/{tag}/objects:
     $ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D~1objects"
 
+  /metalakes/{metalake}/tags/objects:

Review Comment:
   cc @jerryshao  @jerqi 



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2206536614


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsFailureEvent.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event that is triggered when listing metadata objects for multiple tags fails. */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsFailureEvent extends TagFailureEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsFailureEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were being listed.
+   * @param tagNames The names of the tags for which metadata objects listing failed.
+   * @param failure The exception that caused the failure.
+   */
+  public ListMetadataObjectsForTagsFailureEvent(
+      String user, String metalake, String[] tagNames, Exception failure) {
+    super(
+        user,
+        NameIdentifierUtil.ofTag(metalake, tagNames[0]),
+        failure); // Use first tag for identifier
+    this.tagNames = tagNames;
+  }
+
+  /**
+   * Returns the tag names.
+   *
+   * @return the tag names.
+   */
+  public String[] getTagNames() {

Review Comment:
   could you change `getTagNames` to `tagNames` too?



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2195739736


##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -226,6 +227,42 @@ public MetadataObject[] listMetadataObjectsForTag(String metalake, String name)
         });
   }
 
+  public MetadataObject[] listMetadataObjectsForTags(String metalake, String[] names)
+      throws NoSuchTagException {
+    if (names == null || names.length == 0) {
+      return new MetadataObject[0];
+    }
+    NameIdentifier[] tagIds =
+        Arrays.stream(names)
+            .map(name -> NameIdentifierUtil.ofTag(metalake, name))
+            .toArray(NameIdentifier[]::new);
+    NameIdentifier lockId = tagIds[0];
+    return TreeLockUtils.doWithTreeLock(
+        lockId,
+        LockType.READ,

Review Comment:
   @mchades I am not familiar with `TreeLockUtils` here, but would locking at metalake level help? for example:
   ```suggestion
       return TreeLockUtils.doWithTreeLock(
           NameIdentifier.of(metalake),
           LockType.READ,
   ```



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#issuecomment-3125090408

   @jerryshao This is a new feature for tag operations. Would you like to review it?


-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2188875926


##########
docs/open-api/openapi.yaml:
##########
@@ -77,6 +77,9 @@ paths:
   /metalakes/{metalake}/tags/{tag}/objects:
     $ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D~1objects"
 
+  /metalakes/{metalake}/tags/objects:

Review Comment:
   I realize that this request path may conflict with getting a tag? We may need to define a new path for the op
   
   The following are two solutions that come to my mind:
   1. Treat `objects` as a reserved tag name, which may break compatibility. (If the user already has a tag named `objects`, it cannot be retrieved anymore)
   2. using `GET /metalakes/{metalake}/objects?tags=tag1,tag2`
   
   I prefer the solution 2, WDYT?



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2195704633


##########
docs/open-api/openapi.yaml:
##########
@@ -77,6 +77,9 @@ paths:
   /metalakes/{metalake}/tags/{tag}/objects:
     $ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D~1objects"
 
+  /metalakes/{metalake}/tags/objects:

Review Comment:
   fixed



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2189064750


##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -226,6 +227,42 @@ public MetadataObject[] listMetadataObjectsForTag(String metalake, String name)
         });
   }
 
+  public MetadataObject[] listMetadataObjectsForTags(String metalake, String[] names)
+      throws NoSuchTagException {
+    if (names == null || names.length == 0) {
+      return new MetadataObject[0];
+    }
+    NameIdentifier[] tagIds =
+        Arrays.stream(names)
+            .map(name -> NameIdentifierUtil.ofTag(metalake, name))
+            .toArray(NameIdentifier[]::new);
+    NameIdentifier lockId = tagIds[0];
+    return TreeLockUtils.doWithTreeLock(
+        lockId,
+        LockType.READ,

Review Comment:
   In this case, we may need to use the `read` lock of tag's parent.



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2206144360


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier
+    this.tagNames = tagNames;
+  }
+
+  /**
+   * Returns the tag names.
+   *
+   * @return the tag names.
+   */
+  public String[] getTagNames() {

Review Comment:
   fixed!



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2205986659


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   @FANNG1 @mchades since `TagEvent` was designed to handle single tag identifier, the approach that requires the least code to be changed I can see now is to build a multi-tag identifier, for example:
   ```suggestion
   public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
     super(user, createTagListIdentifier(metalake, tagNames));
     this.tagNames = tagNames;
   }
   
   // in some common utils dir
   private static NameIdentifier createTagListIdentifier(String metalake, String[] tagNames) {
     String[] sortedTags = Arrays.stream(tagNames).sorted().toArray(String[]::new);
     String compositeTag = String.join(",", sortedTags);
     return NameIdentifierUtil.ofTag(metalake, compositeTag);
   }
   ```
   Pros: represents all tags involved, no breaking change to `TagEvent`
   Cons: long tags list may exceed identifier limits?
   
   If this does not look good for now, how about I go ahead and open an issue for future improvements on 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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2213935387


##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -226,6 +227,41 @@ public MetadataObject[] listMetadataObjectsForTag(String metalake, String name)
         });
   }
 
+  public MetadataObject[] listMetadataObjectsForTags(String metalake, String[] names)
+      throws NoSuchTagException {
+    if (names == null || names.length == 0) {
+      return new MetadataObject[0];
+    }
+    NameIdentifier[] tagIds =
+        Arrays.stream(names)
+            .map(name -> NameIdentifierUtil.ofTag(metalake, name))
+            .toArray(NameIdentifier[]::new);
+    return TreeLockUtils.doWithTreeLock(
+        NameIdentifier.of(metalake),

Review Comment:
   I was assuming that the parent level of a tag is the metalake? linking prev discussion: https://github.com/apache/gravitino/pull/7476#discussion_r2189064750. correct me if i'm wrong🙏🏻



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2203865860


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsEvent.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing metadata objects for multiple
+ * tags.
+ */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsEvent extends TagEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were listed.
+   * @param tagNames The names of the tags for which metadata objects were listed.
+   */
+  public ListMetadataObjectsForTagsEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier

Review Comment:
   I don't have better suggestions yet.



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2195648029


##########
docs/open-api/openapi.yaml:
##########
@@ -77,6 +77,9 @@ paths:
   /metalakes/{metalake}/tags/{tag}/objects:
     $ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D~1objects"
 
+  /metalakes/{metalake}/tags/objects:

Review Comment:
   @mchades solution 2 does sound more practical and makes more sense. I’ll update the path and push the changes. thanks for the review!



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2188914563


##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -226,6 +227,42 @@ public MetadataObject[] listMetadataObjectsForTag(String metalake, String name)
         });
   }
 
+  public MetadataObject[] listMetadataObjectsForTags(String metalake, String[] names)
+      throws NoSuchTagException {
+    if (names == null || names.length == 0) {
+      return new MetadataObject[0];
+    }
+    NameIdentifier[] tagIds =
+        Arrays.stream(names)
+            .map(name -> NameIdentifierUtil.ofTag(metalake, name))
+            .toArray(NameIdentifier[]::new);
+    NameIdentifier lockId = tagIds[0];
+    return TreeLockUtils.doWithTreeLock(
+        lockId,
+        LockType.READ,

Review Comment:
   Locking only one tag seems unable to solve the concurrency issues of other tags, do we have a better way to acquire locks for batch operations? @yuqi1129 



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2208045763


##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsFailureEvent.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event that is triggered when listing metadata objects for multiple tags fails. */
+@DeveloperApi
+public final class ListMetadataObjectsForTagsFailureEvent extends TagFailureEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs an instance of {@code ListMetadataObjectsForTagsFailureEvent}.
+   *
+   * @param user The username of the individual who initiated the metadata objects listing.
+   * @param metalake The metalake from which metadata objects were being listed.
+   * @param tagNames The names of the tags for which metadata objects listing failed.
+   * @param failure The exception that caused the failure.
+   */
+  public ListMetadataObjectsForTagsFailureEvent(
+      String user, String metalake, String[] tagNames, Exception failure) {
+    super(
+        user,
+        NameIdentifierUtil.ofTag(metalake, tagNames[0]),
+        failure); // Use first tag for identifier
+    this.tagNames = tagNames;
+  }
+
+  /**
+   * Returns the tag names.
+   *
+   * @return the tag names.
+   */
+  public String[] getTagNames() {

Review Comment:
   my bad! fixed.



##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagsPreEvent.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.listener.api.event;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents a pre-event for listing metadata objects associated with multiple tags. */
+@DeveloperApi
+public class ListMetadataObjectsForTagsPreEvent extends TagPreEvent {
+  private final String[] tagNames;
+
+  /**
+   * Constructs a new ListMetadataObjectsForTagsPreEvent instance.
+   *
+   * @param user The user performing the operation.
+   * @param metalake The name of the Metalake environment.
+   * @param tagNames The names of the tags.
+   */
+  public ListMetadataObjectsForTagsPreEvent(String user, String metalake, String[] tagNames) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagNames[0])); // Use first tag for identifier
+    this.tagNames = tagNames;
+  }
+
+  /**
+   * Returns the tag names.
+   *
+   * @return the tag names.
+   */
+  public String[] getTagNames() {

Review Comment:
   fixed. thanks!



-- 
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] [#7454] feat(tag): add list metadata objects for tags API [gravitino]

Posted by "yunchipang (via GitHub)" <gi...@apache.org>.
yunchipang commented on PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#issuecomment-3335183559

   sorry for the late reply. @jerryshao @yuqi1129 PTAL at the new fixes. thanks!


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