You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "cool9850311 (via GitHub)" <gi...@apache.org> on 2025/01/01 02:24:39 UTC

[PR] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   What changes were proposed in this pull request?
   use fullName instead of names.get(0) when get role Why are the changes needed?
   Fix: #6004
   
   Does this PR introduce any user-facing change?
   NO
   
   How was this patch tested?
   existing ut


-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   Oh, I see, so I need to change the legacy implement code?



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   Could you modify `MetadataObjects.parse` to make `MetalakeObjects.of(parent, name)` work, 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   The name with dot should be legal name for role instead of illegal name. It shouldn't throw IllegalArgumentException.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #6057:
URL: https://github.com/apache/gravitino/pull/6057


-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   lgtm
   


-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   You should add the test case in TestJdbcBackend instead of this place.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   `role.test` is a legal name.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java:
##########
@@ -952,6 +953,56 @@ public void testMetaLifeCycleFromCreationToDeletion() throws IOException {
     assertEquals(1, listFilesetVersions(anotherFileset.id()).size());
   }
 
+  @Test
+  public void testGetRoleIdByMetalakeIdAndName() throws IOException {
+    AuditInfo auditInfo =
+        AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();
+    String metalakeName = "testMetalake";
+    String catalogName = "catalog";
+    String roleNameWithDot = "role.with.dot";
+    String roleNameWithoutDot = "roleWithoutDot";
+
+    BaseMetalake metalake =
+        createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(), metalakeName, auditInfo);
+    backend.insert(metalake, false);
+
+    CatalogEntity catalog =
+        createCatalog(
+            RandomIdGenerator.INSTANCE.nextId(),
+            NamespaceUtil.ofCatalog(metalakeName),
+            catalogName,
+            auditInfo);
+    backend.insert(catalog, false);
+
+    RoleEntity roleWithDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithDot, false);
+
+    RoleEntity roleWithoutDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithoutDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithoutDot, false);
+
+    Long metalakeId = MetalakeMetaService.getInstance().getMetalakeIdByName(metalakeName);
+
+    Long roleIdWithDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithDot);
+    assertEquals(roleWithDot.id(), roleIdWithDot);
+
+    Long roleIdWithoutDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithoutDot);
+    assertEquals(roleWithoutDot.id(), roleIdWithoutDot);
+  }

Review Comment:
   You can modify the logic `MetadataObjects.of(null, "role.test", ROLE)`.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   > Could you add a UT for this?
   
   This part is covered by testMetaLifeCycleFromCreationToDeletion in TestJDBCBackend, do i have to add other ut for 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   You should change code of MetadataObjects.of(parent, name, type) Line 53, 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   Yes.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   > Could you modify `MetadataObjects.parse` to make `MetalakeObjects.of(parent, name)` work, too?
   
   Maybe I should add another parse called parseRole, and use if statement in MetalakeObjects.of(String parent, String name, MetadataObject.Type type) to make it works?


-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java:
##########
@@ -952,6 +953,56 @@ public void testMetaLifeCycleFromCreationToDeletion() throws IOException {
     assertEquals(1, listFilesetVersions(anotherFileset.id()).size());
   }
 
+  @Test
+  public void testGetRoleIdByMetalakeIdAndName() throws IOException {
+    AuditInfo auditInfo =
+        AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();
+    String metalakeName = "testMetalake";
+    String catalogName = "catalog";
+    String roleNameWithDot = "role.with.dot";
+    String roleNameWithoutDot = "roleWithoutDot";
+
+    BaseMetalake metalake =
+        createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(), metalakeName, auditInfo);
+    backend.insert(metalake, false);
+
+    CatalogEntity catalog =
+        createCatalog(
+            RandomIdGenerator.INSTANCE.nextId(),
+            NamespaceUtil.ofCatalog(metalakeName),
+            catalogName,
+            auditInfo);
+    backend.insert(catalog, false);
+
+    RoleEntity roleWithDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithDot, false);
+
+    RoleEntity roleWithoutDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithoutDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithoutDot, false);
+
+    Long metalakeId = MetalakeMetaService.getInstance().getMetalakeIdByName(metalakeName);
+
+    Long roleIdWithDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithDot);
+    assertEquals(roleWithDot.id(), roleIdWithDot);
+
+    Long roleIdWithoutDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithoutDot);
+    assertEquals(roleWithoutDot.id(), roleIdWithoutDot);
+  }

Review Comment:
   @jerqi 
   Is this correct?
   just test the method with and without dot



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   Maybe you can add some test case for `MetadataObjects.parse` and `MetalakeObjects.of(parent, name)`?


-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   > > Could you modify `MetadataObjects.parse` to make `MetalakeObjects.of(parent, name)` work, too?
   > 
   > Maybe I should add another parse called parseRole, and use if statement in MetalakeObjects.of(String parent, String name, MetadataObject.Type type) to make it works?
   
   Parse method will be called, too. So we should modify the method `parse` directly.


-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/MetadataObjectService.java:
##########
@@ -52,7 +52,7 @@ public static long getMetadataObjectId(
 
     List<String> names = DOT_SPLITTER.splitToList(fullName);
     if (type == MetadataObject.Type.ROLE) {
-      return RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, names.get(0));
+      return RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, fullName);
     }

Review Comment:
   move 54-56 before 53 so that this is easier to understand?



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java:
##########
@@ -952,6 +953,56 @@ public void testMetaLifeCycleFromCreationToDeletion() throws IOException {
     assertEquals(1, listFilesetVersions(anotherFileset.id()).size());
   }
 
+  @Test
+  public void testGetRoleIdByMetalakeIdAndName() throws IOException {
+    AuditInfo auditInfo =
+        AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();
+    String metalakeName = "testMetalake";
+    String catalogName = "catalog";
+    String roleNameWithDot = "role.with.dot";
+    String roleNameWithoutDot = "roleWithoutDot";
+
+    BaseMetalake metalake =
+        createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(), metalakeName, auditInfo);
+    backend.insert(metalake, false);
+
+    CatalogEntity catalog =
+        createCatalog(
+            RandomIdGenerator.INSTANCE.nextId(),
+            NamespaceUtil.ofCatalog(metalakeName),
+            catalogName,
+            auditInfo);
+    backend.insert(catalog, false);
+
+    RoleEntity roleWithDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithDot, false);
+
+    RoleEntity roleWithoutDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithoutDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithoutDot, false);
+
+    Long metalakeId = MetalakeMetaService.getInstance().getMetalakeIdByName(metalakeName);
+
+    Long roleIdWithDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithDot);
+    assertEquals(roleWithDot.id(), roleIdWithDot);
+
+    Long roleIdWithoutDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithoutDot);
+    assertEquals(roleWithoutDot.id(), roleIdWithoutDot);
+  }

Review Comment:
   You can modify the logic `MetadataObjects.of(null, "role.test", ROLE)`.
   You would better modify the logic of `MetadataObjects.parse`.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java:
##########
@@ -952,6 +953,56 @@ public void testMetaLifeCycleFromCreationToDeletion() throws IOException {
     assertEquals(1, listFilesetVersions(anotherFileset.id()).size());
   }
 
+  @Test
+  public void testGetRoleIdByMetalakeIdAndName() throws IOException {
+    AuditInfo auditInfo =
+        AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();
+    String metalakeName = "testMetalake";
+    String catalogName = "catalog";
+    String roleNameWithDot = "role.with.dot";
+    String roleNameWithoutDot = "roleWithoutDot";
+
+    BaseMetalake metalake =
+        createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(), metalakeName, auditInfo);
+    backend.insert(metalake, false);
+
+    CatalogEntity catalog =
+        createCatalog(
+            RandomIdGenerator.INSTANCE.nextId(),
+            NamespaceUtil.ofCatalog(metalakeName),
+            catalogName,
+            auditInfo);
+    backend.insert(catalog, false);
+
+    RoleEntity roleWithDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithDot, false);
+
+    RoleEntity roleWithoutDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithoutDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithoutDot, false);
+
+    Long metalakeId = MetalakeMetaService.getInstance().getMetalakeIdByName(metalakeName);
+
+    Long roleIdWithDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithDot);
+    assertEquals(roleWithDot.id(), roleIdWithDot);
+
+    Long roleIdWithoutDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithoutDot);
+    assertEquals(roleWithoutDot.id(), roleIdWithoutDot);
+  }

Review Comment:
   Ok



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   Could you add a UT for 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   > > Could you add a UT for this?
   > 
   > This part is covered by testMetaLifeCycleFromCreationToDeletion in TestJDBCBackend, do i have to add other ut for this?
   
   Yes, you need to add a new test case. If the fullName contains `.`, legacy implement will produce an error result. The legacy test case doesn't cover 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   You should change code of MetadataObjects.of(parent, name, type) Line 53, 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   You should create the role metadata object by
   ```
   MetadataObjects.of(null, "role.test", ROLE);
   ```



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   But it does throw the IllegalArgumentException error? 
   



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
api/src/test/java/org/apache/gravitino/TestMetadataObjects.java:
##########
@@ -84,4 +84,17 @@ public void testColumnObject() {
             MetadataObjects.of(
                 Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.COLUMN));
   }
+
+  @Test
+  public void testRoleObject() {
+    // Test legal name
+    MetadataObject roleObject =
+        MetadataObjects.of(Lists.newArrayList("role"), MetadataObject.Type.ROLE);
+    Assertions.assertEquals("role", roleObject.fullName());
+
+    // Test illegal name
+    Assertions.assertThrows(

Review Comment:
   It won't throw `IllegalArgumentException`.



-- 
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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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

   @jerqi 
   could you review the new commit, 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] [#6004] fix: use fullName instead of names.get(0) when get role [gravitino]

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


##########
core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java:
##########
@@ -952,6 +953,56 @@ public void testMetaLifeCycleFromCreationToDeletion() throws IOException {
     assertEquals(1, listFilesetVersions(anotherFileset.id()).size());
   }
 
+  @Test
+  public void testGetRoleIdByMetalakeIdAndName() throws IOException {
+    AuditInfo auditInfo =
+        AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();
+    String metalakeName = "testMetalake";
+    String catalogName = "catalog";
+    String roleNameWithDot = "role.with.dot";
+    String roleNameWithoutDot = "roleWithoutDot";
+
+    BaseMetalake metalake =
+        createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(), metalakeName, auditInfo);
+    backend.insert(metalake, false);
+
+    CatalogEntity catalog =
+        createCatalog(
+            RandomIdGenerator.INSTANCE.nextId(),
+            NamespaceUtil.ofCatalog(metalakeName),
+            catalogName,
+            auditInfo);
+    backend.insert(catalog, false);
+
+    RoleEntity roleWithDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithDot, false);
+
+    RoleEntity roleWithoutDot =
+        createRoleEntity(
+            RandomIdGenerator.INSTANCE.nextId(),
+            AuthorizationUtils.ofRoleNamespace(metalakeName),
+            roleNameWithoutDot,
+            auditInfo,
+            catalogName);
+    backend.insert(roleWithoutDot, false);
+
+    Long metalakeId = MetalakeMetaService.getInstance().getMetalakeIdByName(metalakeName);
+
+    Long roleIdWithDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithDot);
+    assertEquals(roleWithDot.id(), roleIdWithDot);
+
+    Long roleIdWithoutDot =
+        RoleMetaService.getInstance().getRoleIdByMetalakeIdAndName(metalakeId, roleNameWithoutDot);
+    assertEquals(roleWithoutDot.id(), roleIdWithoutDot);
+  }

Review Comment:
   ```
   public static MetadataObject of(List<String> names, MetadataObject.Type type) {
       Preconditions.checkArgument(names != null, "Cannot create a metadata object with null names");
       Preconditions.checkArgument(!names.isEmpty(), "Cannot create a metadata object with no names");
       Preconditions.checkArgument(
           names.size() <= 4,
           "Cannot create a metadata object with the name length which is greater than 4");
       Preconditions.checkArgument(type != null, "Cannot create a metadata object with no type");
   
       Preconditions.checkArgument(
           names.size() != 1
               || type == MetadataObject.Type.CATALOG
               || type == MetadataObject.Type.METALAKE
               || type == MetadataObject.Type.ROLE,
           "If the length of names is 1, it must be the CATALOG, METALAKE, or ROLE type");
   
       Preconditions.checkArgument(
           names.size() != 2 || type == MetadataObject.Type.SCHEMA,
           "If the length of names is 2, it must be the SCHEMA type");
   
       Preconditions.checkArgument(
           names.size() != 3
               || type == MetadataObject.Type.FILESET
               || type == MetadataObject.Type.TABLE
               || type == MetadataObject.Type.TOPIC
               || type == MetadataObject.Type.MODEL,
           "If the length of names is 3, it must be FILESET, TABLE, TOPIC or MODEL");
   
       Preconditions.checkArgument(
           names.size() != 4 || type == MetadataObject.Type.COLUMN,
           "If the length of names is 4, it must be COLUMN");
   
       for (String name : names) {
         checkName(name);
       }
   
       return new MetadataObjectImpl(getParentFullName(names), getLastName(names), type);
     }
   ```
   I am kinda confused now
   So what is the Rule of Role name?
   Does it have length limit?
   For current impl
   if Role name contains dot
   insertRelation will throw IllegalArgumentException, cause it will run through `MetadataObjects.of(null, "role.test", ROLE);` and above checks and conflict with "must be the * type" Preconditions
   insert and other methods will not throw any exception
   



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