jerryshao commented on code in PR #4109:
URL: https://github.com/apache/gravitino/pull/4109#discussion_r1675361650


##########
core/src/main/java/com/datastrato/gravitino/storage/relational/mapper/TagMetadataObjectRelMapper.java:
##########
@@ -18,13 +18,113 @@
  */
 package com.datastrato.gravitino.storage.relational.mapper;
 
+import com.datastrato.gravitino.storage.relational.po.TagMetadataObjectRelPO;
+import com.datastrato.gravitino.storage.relational.po.TagPO;
+import java.util.List;
 import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
 public interface TagMetadataObjectRelMapper {
   String TAG_METADATA_OBJECT_RELATION_TABLE_NAME = "tag_relation_meta";
 
+  @Select(
+      "SELECT tm.tag_id as tagId, tm.tag_name as tagName,"
+          + " tm.metalake_id as metalakeId, tm.tag_comment as comment, 
tm.properties as properties,"
+          + " tm.audit_info as auditInfo,"
+          + " tm.current_version as currentVersion,"
+          + " tm.last_version as lastVersion,"
+          + " tm.deleted_at as deletedAt"
+          + " FROM "
+          + TagMetaMapper.TAG_TABLE_NAME
+          + " tm JOIN "
+          + TAG_METADATA_OBJECT_RELATION_TABLE_NAME
+          + " te ON tm.tag_id = te.tag_id"
+          + " WHERE te.metadata_object_id = #{metadataObjectId}"
+          + " AND te.metadata_object_type = #{metadataObjectType} AND 
te.deleted_at = 0"
+          + " AND tm.deleted_at = 0")
+  List<TagPO> listTagPOsByMetadataObjectIdAndType(
+      @Param("metadataObjectId") Long metadataObjectId,
+      @Param("metadataObjectType") String metadataObjectType);

Review Comment:
   From my understanding that `metadata_object_id` is unique no matter what 
type it is, so I didn't add the `metadata_object_type` here. If there's a 
chance that id will be duplicated for different types, then we need to add this 
to the unique key.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to