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: [email protected]

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

Reply via email to