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


##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNamespaceWrapper.java:
##########
@@ -136,39 +142,297 @@ public ListNamespacesResponse listNamespaces(
   }
 
   @Override
-  public DescribeNamespaceResponse describeNamespace(String id, String 
delimiter) {
-    throw new UnsupportedOperationException("Not implemented yet");
+  public DescribeNamespaceResponse describeNamespace(String namespaceId, 
String delimiter) {
+    ObjectIdentifier nsId = ObjectIdentifier.of(namespaceId, delimiter);
+    Preconditions.checkArgument(
+        nsId.levels() <= 2, "Expected at most 2-level namespace but got: %s", 
namespaceId);
+
+    Catalog catalog = loadAndValidateLakehouseCatalog(nsId.levelAtListPos(0));
+    Map<String, String> properties = Maps.newHashMap();
+
+    switch (nsId.levels()) {
+      case 0:
+        
Optional.ofNullable(catalog.properties()).ifPresent(properties::putAll);
+        break;
+      case 1:
+        String schemaName = nsId.levelAtListPos(1);
+        Schema schema = catalog.asSchemas().loadSchema(schemaName);
+        Optional.ofNullable(schema.properties()).ifPresent(properties::putAll);
+        break;
+      default:
+        throw new IllegalArgumentException(
+            "Expected at most 2-level namespace but got: " + namespaceId);
+    }
+
+    DescribeNamespaceResponse response = new DescribeNamespaceResponse();
+    response.setProperties(properties);
+    return response;
   }
 
   @Override
   public CreateNamespaceResponse createNamespace(
-      String id,
+      String namespaceId,
       String delimiter,
       CreateNamespaceRequest.ModeEnum mode,
       Map<String, String> properties) {
-    throw new UnsupportedOperationException("Not implemented yet");
+    ObjectIdentifier nsId = ObjectIdentifier.of(namespaceId, delimiter);
+    Preconditions.checkArgument(
+        nsId.levels() <= 2, "Expected at most 2-level namespace but got: %s", 
namespaceId);
+
+    switch (nsId.levels()) {
+      case 0:
+        return createOrUpdateCatalog(nsId.levelAtListPos(0), mode, properties);
+      case 1:
+        return createOrUpdateSchema(
+            nsId.levelAtListPos(0), nsId.levelAtListPos(1), mode, properties);
+      default:
+        throw new IllegalArgumentException(
+            "Expected at most 2-level namespace but got: " + namespaceId);
+    }
   }
 
   @Override
   public DropNamespaceResponse dropNamespace(
-      String id,
+      String namespaceId,
       String delimiter,
       DropNamespaceRequest.ModeEnum mode,
       DropNamespaceRequest.BehaviorEnum behavior) {
-    throw new UnsupportedOperationException("Not implemented yet");
+    ObjectIdentifier nsId = ObjectIdentifier.of(namespaceId, delimiter);
+    Preconditions.checkArgument(
+        nsId.levels() <= 2, "Expected at most 2-level namespace but got: %s", 
namespaceId);
+
+    switch (nsId.levels()) {
+      case 0:
+        return dropCatalog(nsId.levelAtListPos(0), mode, behavior);
+      case 1:
+        return dropSchema(nsId.levelAtListPos(0), nsId.levelAtListPos(1), 
mode, behavior);
+      default:
+        throw new IllegalArgumentException(
+            "Expected at most 2-level namespace but got: " + namespaceId);
+    }
   }
 
   @Override
-  public void namespaceExists(String id, String delimiter) throws 
LanceNamespaceException {}
+  public void namespaceExists(String id, String delimiter) throws 
LanceNamespaceException {

Review Comment:
   I think if you want to change the `id` to `namespaceId`, you'd better unify 
them all.



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