mchades commented on code in PR #4108:
URL: https://github.com/apache/gravitino/pull/4108#discussion_r1677951910


##########
core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java:
##########
@@ -395,24 +399,69 @@ public Catalog createCatalog(
     }
   }
 
-  private Pair<Map<String, String>, Map<String, String>> 
getCatalogAlterProperty(
-      CatalogChange... catalogChanges) {
-    Map<String, String> upserts = Maps.newHashMap();
-    Map<String, String> deletes = Maps.newHashMap();
+  /**
+   * Test whether a catalog can be created with the specified parameters, 
without actually creating
+   * it.
+   *
+   * @param ident The identifier of the catalog to be tested.
+   * @param type the type of the catalog.
+   * @param provider the provider of the catalog.
+   * @param comment the comment of the catalog.
+   * @param properties the properties of the catalog.
+   */
+  @Override
+  public void testConnection(
+      NameIdentifier ident,
+      Catalog.Type type,
+      String provider,
+      String comment,
+      Map<String, String> properties) {
+    NameIdentifier metalakeIdent = 
NameIdentifier.of(ident.namespace().levels());
+    try {
+      if (!store.exists(metalakeIdent, EntityType.METALAKE)) {
+        throw new NoSuchMetalakeException(METALAKE_DOES_NOT_EXIST_MSG, 
metalakeIdent);
+      }
 
-    Arrays.stream(catalogChanges)
-        .forEach(
-            catalogChange -> {
-              if (catalogChange instanceof SetProperty) {
-                SetProperty setProperty = (SetProperty) catalogChange;
-                upserts.put(setProperty.getProperty(), setProperty.getValue());
-              } else if (catalogChange instanceof RemoveProperty) {
-                RemoveProperty removeProperty = (RemoveProperty) catalogChange;
-                deletes.put(removeProperty.getProperty(), 
removeProperty.getProperty());
-              }
-            });
+      if (store.exists(ident, EntityType.CATALOG)) {
+        throw new CatalogAlreadyExistsException("Catalog %s already exists", 
ident);

Review Comment:
   yes, whether the catalog name already exists is also a validation item.



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