World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2479] refactor: separate API for client using: SupportsMetalakes and SupportsCatalogs (#3390)
Shaofeng Shia6afb072b364
diff --git a/api/src/main/java/com/datastrato/gravitino/rel/SupportsCatalogs.java b/api/src/main/java/com/datastrato/gravitino/rel/SupportsCatalogs.javanew file mode 100644index 0000000000..901fc3badf--- /dev/null+++ b/api/src/main/java/com/datastrato/gravitino/rel/SupportsCatalogs.java@@ -0,0 +1,107 @@+/*+ * Copyright 2024 Datastrato Pvt Ltd.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.gravitino.rel;++import com.datastrato.gravitino.Catalog;+import com.datastrato.gravitino.CatalogChange;+import com.datastrato.gravitino.CatalogProvider;+import com.datastrato.gravitino.NameIdentifier;+import com.datastrato.gravitino.annotation.Evolving;+import com.datastrato.gravitino.exceptions.CatalogAlreadyExistsException;+import com.datastrato.gravitino.exceptions.NoSuchCatalogException;+import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;+import java.util.Map;++/**+ * Client interface for supporting catalogs. It includes methods for listing, loading, creating,+ * altering and dropping catalogs.+ */+@Evolving+public interface SupportsCatalogs {++ /**+ * List all catalogs in the metalake.+ *+ * @return The list of catalog's name identifiers.+ * @throws NoSuchMetalakeException If the metalake with namespace does not exist.+ */+ NameIdentifier[] listCatalogs() throws NoSuchMetalakeException;++ /**+ * List all catalogs with their information in the metalake.+ *+ * @return The list of catalog's information.+ * @throws NoSuchMetalakeException If the metalake with namespace does not exist.+ */+ Catalog[] listCatalogsInfo() throws NoSuchMetalakeException;++ /**+ * Load a catalog by its identifier.+ *+ * @param catalogName the identifier of the catalog.+ * @return The catalog.+ * @throws NoSuchCatalogException If the catalog does not exist.+ */+ Catalog loadCatalog(String catalogName) throws NoSuchCatalogException;++ /**+ * Check if a catalog exists.+ *+ * @param catalogName The identifier of the catalog.+ * @return True if the catalog exists, false otherwise.+ */+ default boolean catalogExists(String catalogName) {+ try {+ loadCatalog(catalogName);+ return true;+ } catch (NoSuchCatalogException e) {+ return false;+ }+ }++ /**+ * Create a catalog with specified identifier.+ *+ * <p>The parameter "provider" is a short name of the catalog, used to tell Gravitino which+ * catalog should be created. The short name should be the same as the {@link CatalogProvider}+ * interface provided.+ *+ * @param catalogName the name of the catalog.+ * @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.+ * @return The created catalog.+ * @throws NoSuchMetalakeException If the metalake does not exist.+ * @throws CatalogAlreadyExistsException If the catalog already exists.+ */+ Catalog createCatalog(+ String catalogName,+ Catalog.Type type,+ String provider,+ String comment,+ Map<String, String> properties)+ throws NoSuchMetalakeException, CatalogAlreadyExistsException;++ /**+ * Alter a catalog with specified identifier.+ *+ * @param catalogName the identifier of the catalog.+ * @param changes the changes to apply to the catalog.+ * @return The altered catalog.+ * @throws NoSuchCatalogException If the catalog does not exist.+ * @throws IllegalArgumentException If the changes cannot be applied to the catalog.+ */+ Catalog alterCatalog(String catalogName, CatalogChange... changes)+ throws NoSuchCatalogException, IllegalArgumentException;++ /**+ * Drop a catalog with specified identifier.+ *+ * @param catalogName the name of the catalog.+ * @return True if the catalog was dropped, false otherwise.+ */+ boolean dropCatalog(String catalogName);+}diff --git a/api/src/main/java/com/datastrato/gravitino/rel/SupportsMetalakes.java b/api/src/main/java/com/datastrato/gravitino/rel/SupportsMetalakes.javanew file mode 100644index 0000000000..ca2e89c217--- /dev/null+++ b/api/src/main/java/com/datastrato/gravitino/rel/SupportsMetalakes.java@@ -0,0 +1,83 @@+/*+ * Copyright 2024 Datastrato Pvt Ltd.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.gravitino.rel;++import com.datastrato.gravitino.Metalake;+import com.datastrato.gravitino.MetalakeChange;+import com.datastrato.gravitino.annotation.Evolving;+import com.datastrato.gravitino.exceptions.MetalakeAlreadyExistsException;+import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;+import java.util.Map;++/**+ * Client interface for supporting metalakes. It includes methods for listing, loading, creating,+ * altering and dropping metalakes.+ */+@Evolving+public interface SupportsMetalakes {++ /**+ * List all metalakes.+ *+ * @return The list of metalakes.+ */+ Metalake[] listMetalakes();++ /**+ * Load a metalake by its identifier.+ *+ * @param name the name of the metalake.+ * @return The metalake.+ * @throws NoSuchMetalakeException If the metalake does not exist.+ */+ Metalake loadMetalake(String name) throws NoSuchMetalakeException;++ /**+ * Check if a metalake exists.+ *+ * @param name The name of the metalake.+ * @return True if the metalake exists, false otherwise.+ */+ default boolean metalakeExists(String name) {+ try {+ loadMetalake(name);+ return true;+ } catch (NoSuchMetalakeException e) {+ return false;+ }+ }++ /**+ * Create a metalake with specified identifier.+ *+ * @param name The name of the metalake.+ * @param comment The comment of the metalake.+ * @param properties The properties of the metalake.+ * @return The created metalake.+ * @throws MetalakeAlreadyExistsException If the metalake already exists.+ */+ Metalake createMetalake(String name, String comment, Map<String, String> properties)+ throws MetalakeAlreadyExistsException;++ /**+ * Alter a metalake with specified identifier.+ *+ * @param name The name of the metalake.+ * @param changes The changes to apply.+ * @return The altered metalake.+ * @throws NoSuchMetalakeException If the metalake does not exist.+ * @throws IllegalArgumentException If the changes cannot be applied to the metalake.+ */+ Metalake alterMetalake(String name, MetalakeChange... changes)+ throws NoSuchMetalakeException, IllegalArgumentException;++ /**+ * Drop a metalake with specified identifier.+ *+ * @param name The identifier of the metalake.+ * @return True if the metalake was dropped, false otherwise.+ */+ boolean dropMetalake(String name);+}diff --git a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.javaindex 6668d7fb69..1a40d840f3 100644--- a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java+++ b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java@@ -67,7 +67,7 @@ public class HadoopCatalogIT extends AbstractIT {@AfterAllpublic static void stop() throws IOException {- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);if (hdfs != null) {hdfs.close();@@ -85,8 +85,8 @@ public class HadoopCatalogIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -94,13 +94,9 @@ public class HadoopCatalogIT extends AbstractIT {private static void createCatalog() {metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.FILESET,- provider,- "comment",- ImmutableMap.of());+ catalogName, Catalog.Type.FILESET, provider, "comment", ImmutableMap.of());- catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ catalog = metalake.loadCatalog(catalogName);}private static void createSchema() {@@ -547,11 +543,7 @@ public class HadoopCatalogIT extends AbstractIT {// Create a catalog without specifying location.Catalog filesetCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.FILESET,- provider,- "comment",- ImmutableMap.of());+ catalogName, Catalog.Type.FILESET, provider, "comment", ImmutableMap.of());// Create a schema without specifying location.String schemaName =@@ -574,11 +566,9 @@ public class HadoopCatalogIT extends AbstractIT {"schema should not be exists");// Drop the catalog.- dropped = metalake.dropCatalog(NameIdentifier.of(metalakeName, catalogName));+ dropped = metalake.dropCatalog(catalogName);Assertions.assertTrue(dropped, "catalog should be dropped");- Assertions.assertFalse(- metalake.catalogExists(NameIdentifier.of(metalakeName, catalogName)),- "catalog should not be exists");+ Assertions.assertFalse(metalake.catalogExists(catalogName), "catalog should not be exists");}private Fileset createFileset(diff --git a/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/CatalogHiveIT.java b/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/CatalogHiveIT.javaindex bd12d29b12..7a93ca81fa 100644--- a/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/CatalogHiveIT.java+++ b/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/CatalogHiveIT.java@@ -199,7 +199,7 @@ public class CatalogHiveIT extends AbstractIT {@AfterAllpublic static void stop() throws IOException {- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);if (hiveClientPool != null) {hiveClientPool.close();}@@ -232,8 +232,8 @@ public class CatalogHiveIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -243,14 +243,9 @@ public class CatalogHiveIT extends AbstractIT {Map<String, String> properties = Maps.newHashMap();properties.put(METASTORE_URIS, HIVE_METASTORE_URIS);- metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- properties);+ metalake.createCatalog(catalogName, Catalog.Type.RELATIONAL, provider, "comment", properties);- catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ catalog = metalake.loadCatalog(catalogName);}private static void createSchema() throws TException, InterruptedException {@@ -1257,8 +1252,8 @@ public class CatalogHiveIT extends AbstractIT {public void testAlterSchema() throws TException, InterruptedException {NameIdentifier ident = NameIdentifier.of(metalakeName, catalogName, schemaName);- GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeName));- Catalog catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ GravitinoMetalake metalake = client.loadMetalake(metalakeName);+ Catalog catalog = metalake.loadCatalog(catalogName);Schema schema = catalog.asSchemas().loadSchema(ident);Assertions.assertNull(schema.auditInfo().lastModifier());Assertions.assertEquals(AuthConstants.ANONYMOUS_USER, schema.auditInfo().creator());@@ -1285,29 +1280,29 @@ public class CatalogHiveIT extends AbstractIT {@Testvoid testLoadEntityWithSamePrefix() {- GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeName));- Catalog catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ GravitinoMetalake metalake = client.loadMetalake(metalakeName);+ Catalog catalog = metalake.loadCatalog(catalogName);Assertions.assertNotNull(catalog);for (int i = 1; i < metalakeName.length(); i++) {// We can't get the metalake by prefixfinal int length = i;final NameIdentifier id = NameIdentifier.of(metalakeName.substring(0, length));- Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(id));+ Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(id.name()));}final NameIdentifier idA = NameIdentifier.of(metalakeName + "a");- Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(idA));+ Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(idA.name()));for (int i = 1; i < catalogName.length(); i++) {// We can't get the catalog by prefixfinal int length = i;final NameIdentifier id = NameIdentifier.of(metalakeName, catalogName.substring(0, length));- Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(id));+ Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(id.name()));}// We can't load the catalog.final NameIdentifier idB = NameIdentifier.of(metalakeName, catalogName + "a");- Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(idB));+ Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(idB.name()));SupportsSchemas schemas = catalog.asSchemas();@@ -1339,48 +1334,51 @@ public class CatalogHiveIT extends AbstractIT {@Testvoid testAlterEntityName() {String metalakeName = GravitinoITUtils.genRandomName("CatalogHiveIT_metalake");- client.createMetalake(NameIdentifier.of(metalakeName), "", ImmutableMap.of());- final GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "", ImmutableMap.of());+ final GravitinoMetalake metalake = client.loadMetalake(metalakeName);String newMetalakeName = GravitinoITUtils.genRandomName("CatalogHiveIT_metalake_new");// Test rename metalakeNameIdentifier id = NameIdentifier.of(metalakeName);NameIdentifier newId = NameIdentifier.of(newMetalakeName);for (int i = 0; i < 2; i++) {- Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(newId));- client.alterMetalake(id, MetalakeChange.rename(newMetalakeName));- client.loadMetalake(newId);- Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(id));-- client.alterMetalake(newId, MetalakeChange.rename(metalakeName));- client.loadMetalake(id);- Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(newId));+ Assertions.assertThrows(+ NoSuchMetalakeException.class, () -> client.loadMetalake(newId.name()));+ client.alterMetalake(id.name(), MetalakeChange.rename(newMetalakeName));+ client.loadMetalake(newId.name());+ Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(id.name()));++ client.alterMetalake(newId.name(), MetalakeChange.rename(metalakeName));+ client.loadMetalake(id.name());+ Assertions.assertThrows(+ NoSuchMetalakeException.class, () -> client.loadMetalake(newId.name()));}String catalogName = GravitinoITUtils.genRandomName("CatalogHiveIT_catalog");metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,provider,"comment",ImmutableMap.of(METASTORE_URIS, HIVE_METASTORE_URIS));- Catalog catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);// Test rename catalogString newCatalogName = GravitinoITUtils.genRandomName("CatalogHiveIT_catalog_new");NameIdentifier newId2 = NameIdentifier.of(metalakeName, newMetalakeName);NameIdentifier oldId = NameIdentifier.of(metalakeName, catalogName);for (int i = 0; i < 2; i++) {- Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(newId2));- metalake.alterCatalog(- NameIdentifier.of(metalakeName, catalogName), CatalogChange.rename(newCatalogName));- metalake.loadCatalog(NameIdentifier.of(metalakeName, newCatalogName));- Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(oldId));-- metalake.alterCatalog(- NameIdentifier.of(metalakeName, newCatalogName), CatalogChange.rename(catalogName));- catalog = metalake.loadCatalog(oldId);- Assertions.assertThrows(NoSuchCatalogException.class, () -> metalake.loadCatalog(newId2));+ Assertions.assertThrows(+ NoSuchCatalogException.class, () -> metalake.loadCatalog(newId2.name()));+ metalake.alterCatalog(catalogName, CatalogChange.rename(newCatalogName));+ metalake.loadCatalog(newCatalogName);+ Assertions.assertThrows(+ NoSuchCatalogException.class, () -> metalake.loadCatalog(oldId.name()));++ metalake.alterCatalog(newCatalogName, CatalogChange.rename(catalogName));+ catalog = metalake.loadCatalog(oldId.name());+ Assertions.assertThrows(+ NoSuchCatalogException.class, () -> metalake.loadCatalog(newId2.name()));}// Schema does not have the rename operation.@@ -1432,23 +1430,22 @@ public class CatalogHiveIT extends AbstractIT {String metalakeName1 = GravitinoITUtils.genRandomName("CatalogHiveIT_metalake1");String metalakeName2 = GravitinoITUtils.genRandomName("CatalogHiveIT_metalake2");- client.createMetalake(NameIdentifier.of(metalakeName1), "comment", Collections.emptyMap());- client.createMetalake(NameIdentifier.of(metalakeName2), "comment", Collections.emptyMap());+ client.createMetalake(metalakeName1, "comment", Collections.emptyMap());+ client.createMetalake(metalakeName2, "comment", Collections.emptyMap());- client.dropMetalake(NameIdentifier.of(metalakeName1));- client.dropMetalake(NameIdentifier.of(metalakeName2));+ client.dropMetalake(metalakeName1);+ client.dropMetalake(metalakeName2);- client.createMetalake(NameIdentifier.of(metalakeName1), "comment", Collections.emptyMap());+ client.createMetalake(metalakeName1, "comment", Collections.emptyMap());- client.alterMetalake(NameIdentifier.of(metalakeName1), MetalakeChange.rename(metalakeName2));+ client.alterMetalake(metalakeName1, MetalakeChange.rename(metalakeName2));- client.loadMetalake(NameIdentifier.of(metalakeName2));+ client.loadMetalake(metalakeName2);- NameIdentifier of = NameIdentifier.of(metalakeName1);Assertions.assertThrows(NoSuchMetalakeException.class,() -> {- client.loadMetalake(of);+ client.loadMetalake(metalakeName1);});}@@ -1646,11 +1643,6 @@ public class CatalogHiveIT extends AbstractIT {properties.put(METASTORE_URIS, HIVE_METASTORE_URIS);properties.put(BaseCatalog.CATALOG_OPERATION_IMPL, customImpl);- metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- properties);+ metalake.createCatalog(catalogName, Catalog.Type.RELATIONAL, provider, "comment", properties);}}diff --git a/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java b/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.javaindex dcc63d4a7d..f8a339e871 100644--- a/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java+++ b/catalogs/catalog-hive/src/test/java/com/datastrato/gravitino/catalog/hive/integration/test/ProxyCatalogHiveIT.java@@ -290,8 +290,8 @@ public class ProxyCatalogHiveIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(METALAKE_NAME), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(METALAKE_NAME));+ client.createMetalake(METALAKE_NAME, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(METALAKE_NAME);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -309,19 +309,14 @@ public class ProxyCatalogHiveIT extends AbstractIT {properties.put(METASTORE_URIS, HIVE_METASTORE_URIS);properties.put(IMPERSONATION_ENABLE, "true");- metalake.createCatalog(- NameIdentifier.of(METALAKE_NAME, CATALOG_NAME),- Catalog.Type.RELATIONAL,- PROVIDER,- "comment",- properties);+ metalake.createCatalog(CATALOG_NAME, Catalog.Type.RELATIONAL, PROVIDER, "comment", properties);- catalog = metalake.loadCatalog(NameIdentifier.of(METALAKE_NAME, CATALOG_NAME));+ catalog = metalake.loadCatalog(CATALOG_NAME);}private static void loadCatalogWithAnotherClient() {- GravitinoMetalake metaLake = anotherClient.loadMetalake(NameIdentifier.of(METALAKE_NAME));- anotherCatalog = metaLake.loadCatalog(NameIdentifier.of(METALAKE_NAME, CATALOG_NAME));+ GravitinoMetalake metaLake = anotherClient.loadMetalake(METALAKE_NAME);+ anotherCatalog = metaLake.loadCatalog(CATALOG_NAME);}public static void setEnv(String key, String value) {diff --git a/catalogs/catalog-jdbc-doris/src/test/java/com/datastrato/gravitino/catalog/doris/integration/test/CatalogDorisIT.java b/catalogs/catalog-jdbc-doris/src/test/java/com/datastrato/gravitino/catalog/doris/integration/test/CatalogDorisIT.javaindex 75bf912012..61a4178410 100644--- a/catalogs/catalog-jdbc-doris/src/test/java/com/datastrato/gravitino/catalog/doris/integration/test/CatalogDorisIT.java+++ b/catalogs/catalog-jdbc-doris/src/test/java/com/datastrato/gravitino/catalog/doris/integration/test/CatalogDorisIT.java@@ -109,7 +109,7 @@ public class CatalogDorisIT extends AbstractIT {@AfterAllpublic void stop() {clearTableAndSchema();- AbstractIT.client.dropMetalake(NameIdentifier.of(metalakeName));+ AbstractIT.client.dropMetalake(metalakeName);}@AfterEach@@ -132,10 +132,8 @@ public class CatalogDorisIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetaLakes.length);GravitinoMetalake createdMetalake =- AbstractIT.client.createMetalake(- NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake =- AbstractIT.client.loadMetalake(NameIdentifier.of(metalakeName));+ AbstractIT.client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = AbstractIT.client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -158,12 +156,12 @@ public class CatalogDorisIT extends AbstractIT {Catalog createdCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,provider,"doris catalog comment",catalogProperties);- Catalog loadCatalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog loadCatalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(createdCatalog, loadCatalog);catalog = loadCatalog;diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.javaindex ec38006b7e..36d34796ff 100644--- a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java+++ b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/AuditCatalogMysqlIT.java@@ -76,7 +76,7 @@ public class AuditCatalogMysqlIT extends AbstractIT {@AfterAllpublic static void stopIntegrationTest() throws IOException, InterruptedException {AbstractIT.stopIntegrationTest();- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);mysqlService.close();}@@ -89,10 +89,7 @@ public class AuditCatalogMysqlIT extends AbstractIT {Assertions.assertEquals(catalog.auditInfo().creator(), catalog.auditInfo().lastModifier());Assertions.assertEquals(catalog.auditInfo().createTime(), catalog.auditInfo().lastModifiedTime());- catalog =- metalake.alterCatalog(- NameIdentifier.of(metalakeName, catalogName),- CatalogChange.setProperty("key1", "value1"));+ catalog = metalake.alterCatalog(catalogName, CatalogChange.setProperty("key1", "value1"));Assertions.assertEquals(expectUser, catalog.auditInfo().creator());Assertions.assertEquals(expectUser, catalog.auditInfo().lastModifier());}@@ -157,11 +154,7 @@ public class AuditCatalogMysqlIT extends AbstractIT {catalogProperties.put(JdbcConfig.PASSWORD.getKey(), MYSQL_CONTAINER.getPassword());return metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- catalogProperties);+ catalogName, Catalog.Type.RELATIONAL, provider, "comment", catalogProperties);}private static void createMetalake() {@@ -169,8 +162,8 @@ public class AuditCatalogMysqlIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;}diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.javaindex 3e6ef5b803..1f2ef1902d 100644--- a/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java+++ b/catalogs/catalog-jdbc-mysql/src/test/java/com/datastrato/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java@@ -138,7 +138,7 @@ public class CatalogMysqlIT extends AbstractIT {@AfterAllpublic void stop() {clearTableAndSchema();- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);mysqlService.close();}@@ -162,8 +162,8 @@ public class CatalogMysqlIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -185,12 +185,8 @@ public class CatalogMysqlIT extends AbstractIT {Catalog createdCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- catalogProperties);- Catalog loadCatalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ catalogName, Catalog.Type.RELATIONAL, provider, "comment", catalogProperties);+ Catalog loadCatalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(createdCatalog, loadCatalog);catalog = loadCatalog;diff --git a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.javaindex 09feacc2f9..b8cc28931c 100644--- a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java+++ b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java@@ -119,7 +119,7 @@ public class CatalogPostgreSqlIT extends AbstractIT {@AfterAllpublic void stop() {clearTableAndSchema();- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);postgreSqlService.close();}@@ -143,8 +143,8 @@ public class CatalogPostgreSqlIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -163,12 +163,8 @@ public class CatalogPostgreSqlIT extends AbstractIT {Catalog createdCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- catalogProperties);- Catalog loadCatalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ catalogName, Catalog.Type.RELATIONAL, provider, "comment", catalogProperties);+ Catalog loadCatalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(createdCatalog, loadCatalog);catalog = loadCatalog;diff --git a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.javaindex 6841f0315f..0a52b0b9d5 100644--- a/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java+++ b/catalogs/catalog-jdbc-postgresql/src/test/java/com/datastrato/gravitino/catalog/postgresql/integration/test/TestMultipleJDBCLoad.java@@ -85,7 +85,7 @@ public class TestMultipleJDBCLoad extends AbstractIT {String metalakeName = RandomNameUtils.genRandomName("it_metalake");String postgreSqlCatalogName = RandomNameUtils.genRandomName("it_postgresql");GravitinoMetalake metalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());Map<String, String> pgConf = Maps.newHashMap();pgConf.put(JdbcConfig.JDBC_URL.getKey(), postgreSQLContainer.getJdbcUrl(TEST_DB_NAME));@@ -97,11 +97,7 @@ public class TestMultipleJDBCLoad extends AbstractIT {Catalog postgreSqlCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, postgreSqlCatalogName),- Catalog.Type.RELATIONAL,- "jdbc-postgresql",- "comment",- pgConf);+ postgreSqlCatalogName, Catalog.Type.RELATIONAL, "jdbc-postgresql", "comment", pgConf);Map<String, String> mysqlConf = Maps.newHashMap();@@ -112,11 +108,7 @@ public class TestMultipleJDBCLoad extends AbstractIT {String mysqlCatalogName = RandomNameUtils.genRandomName("it_mysql");Catalog mysqlCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, mysqlCatalogName),- Catalog.Type.RELATIONAL,- "jdbc-mysql",- "comment",- mysqlConf);+ mysqlCatalogName, Catalog.Type.RELATIONAL, "jdbc-mysql", "comment", mysqlConf);NameIdentifier[] nameIdentifiers =mysqlCatalog.asSchemas().listSchemas(Namespace.of(metalakeName, mysqlCatalogName));diff --git a/catalogs/catalog-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java b/catalogs/catalog-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.javaindex 2636f2c236..82d5505b81 100644--- a/catalogs/catalog-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java+++ b/catalogs/catalog-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/integration/test/CatalogKafkaIT.java@@ -97,7 +97,7 @@ public class CatalogKafkaIT extends AbstractIT {@AfterAllpublic static void shutdown() {- client.dropMetalake(NameIdentifier.of(METALAKE_NAME));+ client.dropMetalake(METALAKE_NAME);if (adminClient != null) {adminClient.close();}@@ -122,25 +122,24 @@ public class CatalogKafkaIT extends AbstractIT {Assertions.assertEquals(properties, createdCatalog.properties());// test load catalog- Catalog loadedCatalog = metalake.loadCatalog(NameIdentifier.of(METALAKE_NAME, catalogName));+ Catalog loadedCatalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(createdCatalog, loadedCatalog);// test alter catalogCatalog alteredCatalog =metalake.alterCatalog(- NameIdentifier.of(METALAKE_NAME, catalogName),+ catalogName,CatalogChange.updateComment("new comment"),CatalogChange.removeProperty("key1"));Assertions.assertEquals("new comment", alteredCatalog.comment());Assertions.assertFalse(alteredCatalog.properties().containsKey("key1"));// test drop catalog- boolean dropped = metalake.dropCatalog(NameIdentifier.of(METALAKE_NAME, catalogName));+ boolean dropped = metalake.dropCatalog(catalogName);Assertions.assertTrue(dropped);Exception exception =Assertions.assertThrows(- NoSuchCatalogException.class,- () -> metalake.loadCatalog(NameIdentifier.of(METALAKE_NAME, catalogName)));+ NoSuchCatalogException.class, () -> metalake.loadCatalog(catalogName));Assertions.assertTrue(exception.getMessage().contains(catalogName));// assert topic exists in Kafka after catalog droppedAssertions.assertFalse(adminClient.listTopics().names().get().isEmpty());@@ -154,7 +153,7 @@ public class CatalogKafkaIT extends AbstractIT {IllegalArgumentException.class,() ->metalake.createCatalog(- NameIdentifier.of(METALAKE_NAME, catalogName),+ catalogName,Catalog.Type.MESSAGING,PROVIDER,"comment",@@ -166,7 +165,7 @@ public class CatalogKafkaIT extends AbstractIT {IllegalArgumentException.class,() ->metalake.createCatalog(- NameIdentifier.of(METALAKE_NAME, catalogName),+ catalogName,Catalog.Type.MESSAGING,PROVIDER,"comment",@@ -483,8 +482,8 @@ public class CatalogKafkaIT extends AbstractIT {private static void createMetalake() {GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(METALAKE_NAME), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(METALAKE_NAME));+ client.createMetalake(METALAKE_NAME, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(METALAKE_NAME);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -492,12 +491,7 @@ public class CatalogKafkaIT extends AbstractIT {private static Catalog createCatalog(String catalogName, String comment, Map<String, String> properties) {- metalake.createCatalog(- NameIdentifier.of(METALAKE_NAME, catalogName),- Catalog.Type.MESSAGING,- PROVIDER,- comment,- properties);- return metalake.loadCatalog(NameIdentifier.of(METALAKE_NAME, catalogName));+ metalake.createCatalog(catalogName, Catalog.Type.MESSAGING, PROVIDER, comment, properties);+ return metalake.loadCatalog(catalogName);}}diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.javaindex 9830317a46..0afad8e473 100644--- a/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java+++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/CatalogIcebergBaseIT.java@@ -119,7 +119,7 @@ public abstract class CatalogIcebergBaseIT extends AbstractIT {@AfterAllpublic void stop() throws Exception {clearTableAndSchema();- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);spark.close();AbstractIT.stopIntegrationTest();}@@ -171,8 +171,8 @@ public abstract class CatalogIcebergBaseIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -198,12 +198,8 @@ public abstract class CatalogIcebergBaseIT extends AbstractIT {Catalog createdCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- catalogProperties);- Catalog loadCatalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ catalogName, Catalog.Type.RELATIONAL, provider, "comment", catalogProperties);+ Catalog loadCatalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(createdCatalog, loadCatalog);catalog = loadCatalog;diff --git a/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java b/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.javaindex 71481bb242..7924130bd9 100644--- a/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java+++ b/catalogs/catalog-lakehouse-iceberg/src/test/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/integration/test/TestMultipleJDBCLoad.java@@ -82,7 +82,7 @@ public class TestMultipleJDBCLoad extends AbstractIT {String metalakeName = RandomNameUtils.genRandomName("it_metalake");String postgreSqlCatalogName = RandomNameUtils.genRandomName("it_iceberg_postgresql");GravitinoMetalake metalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());Map<String, String> icebergPgConf = Maps.newHashMap();String jdbcUrl = postgreSQLContainer.getJdbcUrl(TEST_DB_NAME);@@ -96,7 +96,7 @@ public class TestMultipleJDBCLoad extends AbstractIT {Catalog postgreSqlCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, postgreSqlCatalogName),+ postgreSqlCatalogName,Catalog.Type.RELATIONAL,"lakehouse-iceberg","comment",@@ -115,7 +115,7 @@ public class TestMultipleJDBCLoad extends AbstractIT {String mysqlCatalogName = RandomNameUtils.genRandomName("it_iceberg_mysql");Catalog mysqlCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, mysqlCatalogName),+ mysqlCatalogName,Catalog.Type.RELATIONAL,"lakehouse-iceberg","comment",diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoAdminClient.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoAdminClient.javaindex aaa15cf41a..5f52cbb151 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoAdminClient.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoAdminClient.java@@ -6,8 +6,6 @@package com.datastrato.gravitino.client;import com.datastrato.gravitino.MetalakeChange;-import com.datastrato.gravitino.NameIdentifier;-import com.datastrato.gravitino.SupportsMetalakes;import com.datastrato.gravitino.authorization.Group;import com.datastrato.gravitino.authorization.Privilege;import com.datastrato.gravitino.authorization.Role;@@ -37,6 +35,7 @@ import com.datastrato.gravitino.exceptions.NoSuchRoleException;import com.datastrato.gravitino.exceptions.NoSuchUserException;import com.datastrato.gravitino.exceptions.RoleAlreadyExistsException;import com.datastrato.gravitino.exceptions.UserAlreadyExistsException;+import com.datastrato.gravitino.rel.SupportsMetalakes;import com.google.common.base.Preconditions;import java.util.Arrays;import java.util.Collections;@@ -103,7 +102,7 @@ public class GravitinoAdminClient extends GravitinoClientBase implements Support/*** Creates a new Metalake using the Gravitino API.*- * @param ident The identifier of the new Metalake.+ * @param name The name of the new Metalake.* @param comment The comment for the new Metalake.* @param properties The properties of the new Metalake.* @return A GravitinoMetalake instance representing the newly created Metalake.@@ -112,11 +111,11 @@ public class GravitinoAdminClient extends GravitinoClientBase implements Support*/@Overridepublic GravitinoMetalake createMetalake(- NameIdentifier ident, String comment, Map<String, String> properties)+ String name, String comment, Map<String, String> properties)throws MetalakeAlreadyExistsException {- NameIdentifier.checkMetalake(ident);+ checkMetalakeName(name);- MetalakeCreateRequest req = new MetalakeCreateRequest(ident.name(), comment, properties);+ MetalakeCreateRequest req = new MetalakeCreateRequest(name, comment, properties);req.validate();MetalakeResponse resp =@@ -134,17 +133,16 @@ public class GravitinoAdminClient extends GravitinoClientBase implements Support/*** Alters a specific Metalake using the Gravitino API.*- * @param ident The identifier of the Metalake to be altered.+ * @param name The name of the Metalake to be altered.* @param changes The changes to be applied to the Metalake.* @return A GravitinoMetalake instance representing the updated Metalake.* @throws NoSuchMetalakeException If the specified Metalake does not exist.* @throws IllegalArgumentException If the provided changes are invalid or not applicable.*/@Override- public GravitinoMetalake alterMetalake(NameIdentifier ident, MetalakeChange... changes)+ public GravitinoMetalake alterMetalake(String name, MetalakeChange... changes)throws NoSuchMetalakeException, IllegalArgumentException {- NameIdentifier.checkMetalake(ident);-+ checkMetalakeName(name);List<MetalakeUpdateRequest> reqs =Arrays.stream(changes).map(DTOConverters::toMetalakeUpdateRequest)@@ -154,7 +152,7 @@ public class GravitinoAdminClient extends GravitinoClientBase implements SupportMetalakeResponse resp =restClient.put(- API_METALAKES_IDENTIFIER_PATH + ident.name(),+ API_METALAKES_IDENTIFIER_PATH + name,updatesRequest,MetalakeResponse.class,Collections.emptyMap(),@@ -167,17 +165,16 @@ public class GravitinoAdminClient extends GravitinoClientBase implements Support/*** Drops a specific Metalake using the Gravitino API.*- * @param ident The identifier of the Metalake to be dropped.+ * @param name The name of the Metalake to be dropped.* @return True if the Metalake was successfully dropped, false otherwise.*/@Override- public boolean dropMetalake(NameIdentifier ident) {- NameIdentifier.checkMetalake(ident);-+ public boolean dropMetalake(String name) {+ checkMetalakeName(name);try {DropResponse resp =restClient.delete(- API_METALAKES_IDENTIFIER_PATH + ident.name(),+ API_METALAKES_IDENTIFIER_PATH + name,DropResponse.class,Collections.emptyMap(),ErrorHandlers.metalakeErrorHandler());@@ -185,7 +182,7 @@ public class GravitinoAdminClient extends GravitinoClientBase implements Supportreturn resp.dropped();} catch (Exception e) {- LOG.warn("Failed to drop metadata {}", ident, e);+ LOG.warn("Failed to drop metadata {}", name, e);return false;}}diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.javaindex 7b763a889e..acee395edb 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClient.java@@ -8,11 +8,10 @@ package com.datastrato.gravitino.client;import com.datastrato.gravitino.Catalog;import com.datastrato.gravitino.CatalogChange;import com.datastrato.gravitino.NameIdentifier;-import com.datastrato.gravitino.Namespace;-import com.datastrato.gravitino.SupportsCatalogs;import com.datastrato.gravitino.exceptions.CatalogAlreadyExistsException;import com.datastrato.gravitino.exceptions.NoSuchCatalogException;import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;+import com.datastrato.gravitino.rel.SupportsCatalogs;import com.google.common.base.Preconditions;import java.util.Map;@@ -45,7 +44,7 @@ public class GravitinoClient extends GravitinoClientBase implements SupportsCataboolean checkVersion,Map<String, String> headers) {super(uri, authDataProvider, checkVersion, headers);- this.metalake = loadMetalake(NameIdentifier.of(metalakeName));+ this.metalake = loadMetalake(metalakeName);}/**@@ -59,40 +58,40 @@ public class GravitinoClient extends GravitinoClientBase implements SupportsCata}@Override- public NameIdentifier[] listCatalogs(Namespace namespace) throws NoSuchMetalakeException {- return getMetalake().listCatalogs(namespace);+ public NameIdentifier[] listCatalogs() throws NoSuchMetalakeException {+ return getMetalake().listCatalogs();}@Override- public Catalog[] listCatalogsInfo(Namespace namespace) throws NoSuchMetalakeException {- return getMetalake().listCatalogsInfo(namespace);+ public Catalog[] listCatalogsInfo() throws NoSuchMetalakeException {+ return getMetalake().listCatalogsInfo();}@Override- public Catalog loadCatalog(NameIdentifier ident) throws NoSuchCatalogException {- return getMetalake().loadCatalog(ident);+ public Catalog loadCatalog(String catalogName) throws NoSuchCatalogException {+ return getMetalake().loadCatalog(catalogName);}@Overridepublic Catalog createCatalog(- NameIdentifier ident,+ String catalogName,Catalog.Type type,String provider,String comment,Map<String, String> properties)throws NoSuchMetalakeException, CatalogAlreadyExistsException {- return getMetalake().createCatalog(ident, type, provider, comment, properties);+ return getMetalake().createCatalog(catalogName, type, provider, comment, properties);}@Override- public Catalog alterCatalog(NameIdentifier ident, CatalogChange... changes)+ public Catalog alterCatalog(String catalogName, CatalogChange... changes)throws NoSuchCatalogException, IllegalArgumentException {- return getMetalake().alterCatalog(ident, changes);+ return getMetalake().alterCatalog(catalogName, changes);}@Override- public boolean dropCatalog(NameIdentifier ident) {- return getMetalake().dropCatalog(ident);+ public boolean dropCatalog(String catalogName) {+ return getMetalake().dropCatalog(catalogName);}/**diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClientBase.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClientBase.javaindex f47f0015bc..308b80ecca 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClientBase.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoClientBase.java@@ -10,6 +10,7 @@ import com.datastrato.gravitino.Version;import com.datastrato.gravitino.dto.responses.MetalakeResponse;import com.datastrato.gravitino.dto.responses.VersionResponse;import com.datastrato.gravitino.exceptions.GravitinoRuntimeException;+import com.datastrato.gravitino.exceptions.IllegalNameIdentifierException;import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;import com.fasterxml.jackson.databind.ObjectMapper;import com.google.common.collect.ImmutableMap;@@ -102,16 +103,17 @@ public abstract class GravitinoClientBase implements Closeable {/*** Loads a specific Metalake from the Gravitino API.*- * @param ident The identifier of the Metalake to be loaded.+ * @param metalakeName The name of the Metalake to be loaded.* @return A GravitinoMetalake instance representing the loaded Metalake.* @throws NoSuchMetalakeException If the specified Metalake does not exist.*/- public GravitinoMetalake loadMetalake(NameIdentifier ident) throws NoSuchMetalakeException {- NameIdentifier.checkMetalake(ident);+ public GravitinoMetalake loadMetalake(String metalakeName) throws NoSuchMetalakeException {++ checkMetalakeName(metalakeName);MetalakeResponse resp =restClient.get(- API_METALAKES_IDENTIFIER_PATH + ident.name(),+ API_METALAKES_IDENTIFIER_PATH + metalakeName,MetalakeResponse.class,Collections.emptyMap(),ErrorHandlers.metalakeErrorHandler());@@ -120,6 +122,16 @@ public abstract class GravitinoClientBase implements Closeable {return DTOConverters.toMetaLake(resp.getMetalake(), restClient);}+ /**+ * Checks the validity of the Metalake name.+ *+ * @param metalakeName the name of the Metalake to be checked.+ * @throws IllegalNameIdentifierException If the Metalake name is invalid.+ */+ public void checkMetalakeName(String metalakeName) {+ NameIdentifier.checkMetalake(NameIdentifier.parse(metalakeName));+ }+/*** Retrieves the version of the Gravitino API.*diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoMetalake.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoMetalake.javaindex 45a2fb8b7e..25f35dcc32 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoMetalake.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/GravitinoMetalake.java@@ -7,8 +7,6 @@ package com.datastrato.gravitino.client;import com.datastrato.gravitino.Catalog;import com.datastrato.gravitino.CatalogChange;import com.datastrato.gravitino.NameIdentifier;-import com.datastrato.gravitino.Namespace;-import com.datastrato.gravitino.SupportsCatalogs;import com.datastrato.gravitino.dto.AuditDTO;import com.datastrato.gravitino.dto.MetalakeDTO;import com.datastrato.gravitino.dto.requests.CatalogCreateRequest;@@ -21,6 +19,7 @@ import com.datastrato.gravitino.dto.responses.EntityListResponse;import com.datastrato.gravitino.exceptions.CatalogAlreadyExistsException;import com.datastrato.gravitino.exceptions.NoSuchCatalogException;import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;+import com.datastrato.gravitino.rel.SupportsCatalogs;import com.google.common.base.Preconditions;import java.util.Arrays;import java.util.Collections;@@ -56,19 +55,17 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {}/**- * List all the catalogs under this metalake with specified namespace.+ * List all the catalogs under this metalake.*- * @param namespace The namespace to list the catalogs under it.* @return A list of {@link NameIdentifier} of the catalogs under the specified namespace.* @throws NoSuchMetalakeException if the metalake with specified namespace does not exist.*/@Override- public NameIdentifier[] listCatalogs(Namespace namespace) throws NoSuchMetalakeException {- Namespace.checkCatalog(namespace);+ public NameIdentifier[] listCatalogs() throws NoSuchMetalakeException {EntityListResponse resp =restClient.get(- String.format("api/metalakes/%s/catalogs", namespace.level(0)),+ String.format("api/metalakes/%s/catalogs", this.name()),EntityListResponse.class,Collections.emptyMap(),ErrorHandlers.catalogErrorHandler());@@ -78,21 +75,19 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {}/**- * List all the catalogs with their information under this metalake with specified namespace.+ * List all the catalogs with their information under this metalake.*- * @param namespace The namespace to list the catalogs under it.* @return A list of {@link Catalog} under the specified namespace.* @throws NoSuchMetalakeException if the metalake with specified namespace does not exist.*/@Override- public Catalog[] listCatalogsInfo(Namespace namespace) throws NoSuchMetalakeException {- Namespace.checkCatalog(namespace);+ public Catalog[] listCatalogsInfo() throws NoSuchMetalakeException {Map<String, String> params = new HashMap<>();params.put("details", "true");CatalogListResponse resp =restClient.get(- String.format("api/metalakes/%s/catalogs", namespace.level(0)),+ String.format("api/metalakes/%s/catalogs", this.name()),params,CatalogListResponse.class,Collections.emptyMap(),@@ -106,17 +101,16 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {/*** Load the catalog with specified identifier.*- * @param ident The identifier of the catalog to load.+ * @param catalogName The identifier of the catalog to load.* @return The {@link Catalog} with specified identifier.* @throws NoSuchCatalogException if the catalog with specified identifier does not exist.*/@Override- public Catalog loadCatalog(NameIdentifier ident) throws NoSuchCatalogException {- NameIdentifier.checkCatalog(ident);+ public Catalog loadCatalog(String catalogName) throws NoSuchCatalogException {CatalogResponse resp =restClient.get(- String.format(API_METALAKES_CATALOGS_PATH, ident.namespace().level(0), ident.name()),+ String.format(API_METALAKES_CATALOGS_PATH, this.name(), catalogName),CatalogResponse.class,Collections.emptyMap(),ErrorHandlers.catalogErrorHandler());@@ -128,7 +122,7 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {/*** Create a new catalog with specified identifier, type, comment and properties.*- * @param ident The identifier of the catalog.+ * @param catalogName The identifier of the catalog.* @param type The type of the catalog.* @param provider The provider of the catalog.* @param comment The comment of the catalog.@@ -139,21 +133,20 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {*/@Overridepublic Catalog createCatalog(- NameIdentifier ident,+ String catalogName,Catalog.Type type,String provider,String comment,Map<String, String> properties)throws NoSuchMetalakeException, CatalogAlreadyExistsException {- NameIdentifier.checkCatalog(ident);CatalogCreateRequest req =- new CatalogCreateRequest(ident.name(), type, provider, comment, properties);+ new CatalogCreateRequest(catalogName, type, provider, comment, properties);req.validate();CatalogResponse resp =restClient.post(- String.format("api/metalakes/%s/catalogs", ident.namespace().level(0)),+ String.format("api/metalakes/%s/catalogs", this.name()),req,CatalogResponse.class,Collections.emptyMap(),@@ -166,16 +159,15 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {/*** Alter the catalog with specified identifier by applying the changes.*- * @param ident the identifier of the catalog.+ * @param catalogName the identifier of the catalog.* @param changes the changes to apply to the catalog.* @return the altered {@link Catalog}.* @throws NoSuchCatalogException if the catalog with specified identifier does not exist.* @throws IllegalArgumentException if the changes are invalid.*/@Override- public Catalog alterCatalog(NameIdentifier ident, CatalogChange... changes)+ public Catalog alterCatalog(String catalogName, CatalogChange... changes)throws NoSuchCatalogException, IllegalArgumentException {- NameIdentifier.checkCatalog(ident);List<CatalogUpdateRequest> reqs =Arrays.stream(changes)@@ -186,7 +178,7 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {CatalogResponse resp =restClient.put(- String.format(API_METALAKES_CATALOGS_PATH, ident.namespace().level(0), ident.name()),+ String.format(API_METALAKES_CATALOGS_PATH, this.name(), catalogName),updatesRequest,CatalogResponse.class,Collections.emptyMap(),@@ -199,17 +191,16 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {/*** Drop the catalog with specified identifier.*- * @param ident the identifier of the catalog.+ * @param catalogName the name of the catalog.* @return true if the catalog is dropped successfully, false otherwise.*/@Override- public boolean dropCatalog(NameIdentifier ident) {- NameIdentifier.checkCatalog(ident);+ public boolean dropCatalog(String catalogName) {try {DropResponse resp =restClient.delete(- String.format(API_METALAKES_CATALOGS_PATH, ident.namespace().level(0), ident.name()),+ String.format(API_METALAKES_CATALOGS_PATH, this.name(), catalogName),DropResponse.class,Collections.emptyMap(),ErrorHandlers.catalogErrorHandler());@@ -217,7 +208,7 @@ public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {return resp.dropped();} catch (Exception e) {- LOG.warn("Failed to drop catalog {}", ident, e);+ LOG.warn("Failed to drop catalog {}", catalogName, e);return false;}}diff --git a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestFilesetCatalog.java b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestFilesetCatalog.javaindex da9392dd6c..a82dbfba2c 100644--- a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestFilesetCatalog.java+++ b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestFilesetCatalog.java@@ -82,11 +82,7 @@ public class TestFilesetCatalog extends TestBase {catalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- CatalogDTO.Type.FILESET,- provider,- "comment",- ImmutableMap.of("k1", "k2"));+ catalogName, CatalogDTO.Type.FILESET, provider, "comment", ImmutableMap.of("k1", "k2"));}@Testdiff --git a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoClient.java b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoClient.javaindex 9a630ce34d..7d150addba 100644--- a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoClient.java+++ b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoClient.java@@ -18,6 +18,7 @@ import com.datastrato.gravitino.dto.responses.MetalakeListResponse;import com.datastrato.gravitino.dto.responses.MetalakeResponse;import com.datastrato.gravitino.dto.responses.VersionResponse;import com.datastrato.gravitino.exceptions.GravitinoRuntimeException;+import com.datastrato.gravitino.exceptions.IllegalNamespaceException;import com.datastrato.gravitino.exceptions.MetalakeAlreadyExistsException;import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;import com.datastrato.gravitino.exceptions.RESTException;@@ -100,7 +101,7 @@ public class TestGravitinoClient extends TestBase {MetalakeResponse resp = new MetalakeResponse(mockMetalake);buildMockResource(Method.GET, "/api/metalakes/mock", null, resp, HttpStatus.SC_OK);NameIdentifier id = NameIdentifier.of("mock");- GravitinoMetalake metaLake = client.loadMetalake(id);+ GravitinoMetalake metaLake = client.loadMetalake(id.name());Assertions.assertEquals("mock", metaLake.name());Assertions.assertEquals("comment", metaLake.comment());Assertions.assertEquals("creator", metaLake.auditInfo().creator());@@ -110,20 +111,23 @@ public class TestGravitinoClient extends TestBase {ErrorResponse.notFound(NoSuchMetalakeException.class.getSimpleName(), "mock error");buildMockResource(Method.GET, "/api/metalakes/mock", null, errorResp, HttpStatus.SC_NOT_FOUND);Throwable excep =- Assertions.assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(id));+ Assertions.assertThrows(+ NoSuchMetalakeException.class, () -> client.loadMetalake(id.name()));Assertions.assertTrue(excep.getMessage().contains("mock error"));// Test illegal metalake name identifier- NameIdentifier badName = NameIdentifier.parse("mock.mock");+ String badName = "mock.mock";Throwable excep1 =- Assertions.assertThrows(IllegalArgumentException.class, () -> client.loadMetalake(badName));+ Assertions.assertThrows(+ IllegalNamespaceException.class, () -> client.loadMetalake(badName));Assertions.assertTrue(excep1.getMessage().contains("Metalake namespace must be non-null and empty"));// Test return unparsed system errorbuildMockResource(Method.GET, "/api/metalakes/mock", null, null, HttpStatus.SC_CONFLICT);- Throwable excep2 = Assertions.assertThrows(RESTException.class, () -> client.loadMetalake(id));+ Throwable excep2 =+ Assertions.assertThrows(RESTException.class, () -> client.loadMetalake(id.name()));Assertions.assertTrue(excep2.getMessage().contains("Error code: " + HttpStatus.SC_CONFLICT));}@@ -142,7 +146,8 @@ public class TestGravitinoClient extends TestBase {MetalakeResponse resp = new MetalakeResponse(mockMetalake);buildMockResource(Method.POST, "/api/metalakes", req, resp, HttpStatus.SC_OK);NameIdentifier id = NameIdentifier.parse("mock");- GravitinoMetalake metaLake = client.createMetalake(id, "comment", Collections.emptyMap());+ GravitinoMetalake metaLake =+ client.createMetalake(id.name(), "comment", Collections.emptyMap());Map<String, String> emptyMap = Collections.emptyMap();Assertions.assertEquals("mock", metaLake.name());@@ -157,14 +162,14 @@ public class TestGravitinoClient extends TestBase {Throwable excep =Assertions.assertThrows(MetalakeAlreadyExistsException.class,- () -> client.createMetalake(id, "comment", emptyMap));+ () -> client.createMetalake(id.name(), "comment", emptyMap));Assertions.assertTrue(excep.getMessage().contains("mock error"));// Test return unparsed system errorbuildMockResource(Method.POST, "/api/metalakes", req, null, HttpStatus.SC_CONFLICT);Throwable excep1 =Assertions.assertThrows(- RESTException.class, () -> client.createMetalake(id, "comment", emptyMap));+ RESTException.class, () -> client.createMetalake(id.name(), "comment", emptyMap));Assertions.assertTrue(excep1.getMessage().contains("Error code: " + HttpStatus.SC_CONFLICT));}@@ -191,7 +196,7 @@ public class TestGravitinoClient extends TestBase {buildMockResource(Method.PUT, "/api/metalakes/mock", req, resp, HttpStatus.SC_OK);NameIdentifier id = NameIdentifier.of("mock");- GravitinoMetalake metaLake = client.alterMetalake(id, changes);+ GravitinoMetalake metaLake = client.alterMetalake(id.name(), changes);Assertions.assertEquals("newName", metaLake.name());Assertions.assertEquals("newComment", metaLake.comment());Assertions.assertEquals("creator", metaLake.auditInfo().creator());@@ -202,11 +207,11 @@ public class TestGravitinoClient extends TestBase {buildMockResource(Method.PUT, "/api/metalakes/mock", req, errorResp, HttpStatus.SC_NOT_FOUND);Throwable excep =Assertions.assertThrows(- NoSuchMetalakeException.class, () -> client.alterMetalake(id, changes));+ NoSuchMetalakeException.class, () -> client.alterMetalake(id.name(), changes));Assertions.assertTrue(excep.getMessage().contains("mock error"));// Test illegal argument- NameIdentifier id2 = NameIdentifier.parse("mock.mock");+ String id2 = "mock.mock";Throwable excep1 =Assertions.assertThrows(IllegalArgumentException.class, () -> client.alterMetalake(id2, changes));@@ -218,22 +223,22 @@ public class TestGravitinoClient extends TestBase {public void testDropMetalake() throws JsonProcessingException {DropResponse resp = new DropResponse(true);buildMockResource(Method.DELETE, "/api/metalakes/mock", null, resp, HttpStatus.SC_OK);- Assertions.assertTrue(client.dropMetalake(NameIdentifier.of("mock")));+ Assertions.assertTrue(client.dropMetalake("mock"));DropResponse resp1 = new DropResponse(false);buildMockResource(Method.DELETE, "/api/metalakes/mock", null, resp1, HttpStatus.SC_OK);- Assertions.assertFalse(client.dropMetalake(NameIdentifier.of("mock")));+ Assertions.assertFalse(client.dropMetalake("mock"));// Test return internal errorErrorResponse errorResp = ErrorResponse.internalError("mock error");buildMockResource(Method.DELETE, "/api/metalakes/mock", null, errorResp, HttpStatus.SC_INTERNAL_SERVER_ERROR);- Assertions.assertFalse(client.dropMetalake(NameIdentifier.of("mock")));+ Assertions.assertFalse(client.dropMetalake("mock"));// Test illegal metalake name identifier- NameIdentifier id = NameIdentifier.parse("mock.mock");+ String badName = "mock.mock";Throwable excep1 =- Assertions.assertThrows(IllegalArgumentException.class, () -> client.dropMetalake(id));+ Assertions.assertThrows(IllegalArgumentException.class, () -> client.dropMetalake(badName));Assertions.assertTrue(excep1.getMessage().contains("Metalake namespace must be non-null and empty"));}diff --git a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoMetalake.java b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoMetalake.javaindex 6000bd1e61..7cdf69a420 100644--- a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoMetalake.java+++ b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestGravitinoMetalake.java@@ -7,7 +7,6 @@ package com.datastrato.gravitino.client;import com.datastrato.gravitino.Catalog;import com.datastrato.gravitino.CatalogChange;import com.datastrato.gravitino.NameIdentifier;-import com.datastrato.gravitino.Namespace;import com.datastrato.gravitino.dto.AuditDTO;import com.datastrato.gravitino.dto.CatalogDTO;import com.datastrato.gravitino.dto.MetalakeDTO;@@ -74,11 +73,10 @@ public class TestGravitinoMetalake extends TestBase {NameIdentifier ident1 = NameIdentifier.of(metalakeName, "mock");NameIdentifier ident2 = NameIdentifier.of(metalakeName, "mock2");- Namespace namespace = Namespace.of(metalakeName);EntityListResponse resp = new EntityListResponse(new NameIdentifier[] {ident1, ident2});buildMockResource(Method.GET, path, null, resp, HttpStatus.SC_OK);- NameIdentifier[] catalogs = gravitinoClient.listCatalogs(namespace);+ NameIdentifier[] catalogs = gravitinoClient.listCatalogs();Assertions.assertEquals(2, catalogs.length);Assertions.assertEquals(ident1, catalogs[0]);@@ -87,21 +85,20 @@ public class TestGravitinoMetalake extends TestBase {// Test return empty catalog listEntityListResponse resp1 = new EntityListResponse(new NameIdentifier[] {});buildMockResource(Method.GET, path, null, resp1, HttpStatus.SC_OK);- NameIdentifier[] catalogs1 = gravitinoClient.listCatalogs(namespace);+ NameIdentifier[] catalogs1 = gravitinoClient.listCatalogs();Assertions.assertEquals(0, catalogs1.length);// Test return internal errorErrorResponse errorResp = ErrorResponse.internalError("mock error");buildMockResource(Method.GET, path, null, errorResp, HttpStatus.SC_INTERNAL_SERVER_ERROR);Throwable ex =- Assertions.assertThrows(- RuntimeException.class, () -> gravitinoClient.listCatalogs(namespace));+ Assertions.assertThrows(RuntimeException.class, () -> gravitinoClient.listCatalogs());Assertions.assertTrue(ex.getMessage().contains("mock error"));// Test return unparsed system errorbuildMockResource(Method.GET, path, null, "mock error", HttpStatus.SC_CONFLICT);Throwable ex1 =- Assertions.assertThrows(RESTException.class, () -> gravitinoClient.listCatalogs(namespace));+ Assertions.assertThrows(RESTException.class, () -> gravitinoClient.listCatalogs());Assertions.assertTrue(ex1.getMessage().contains("Error code: " + HttpStatus.SC_CONFLICT));}@@ -110,8 +107,6 @@ public class TestGravitinoMetalake extends TestBase {String path = "/api/metalakes/" + metalakeName + "/catalogs";Map<String, String> params = Collections.singletonMap("details", "true");- Namespace namespace = Namespace.of(metalakeName);-CatalogDTO mockCatalog1 =CatalogDTO.builder().withName("mock")@@ -134,7 +129,7 @@ public class TestGravitinoMetalake extends TestBase {new CatalogListResponse(new CatalogDTO[] {mockCatalog1, mockCatalog2});buildMockResource(Method.GET, path, null, resp, HttpStatus.SC_OK);- Catalog[] catalogs = gravitinoClient.listCatalogsInfo(namespace);+ Catalog[] catalogs = gravitinoClient.listCatalogsInfo();Assertions.assertEquals(2, catalogs.length);Assertions.assertEquals("mock", catalogs[0].name());Assertions.assertEquals("comment", catalogs[0].comment());@@ -149,7 +144,7 @@ public class TestGravitinoMetalake extends TestBase {buildMockResource(Method.GET, path, params, null, errorResponse, HttpStatus.SC_NOT_FOUND);Throwable ex =Assertions.assertThrows(- NoSuchMetalakeException.class, () -> gravitinoClient.listCatalogsInfo(namespace));+ NoSuchMetalakeException.class, () -> gravitinoClient.listCatalogsInfo());Assertions.assertTrue(ex.getMessage().contains("mock error"));}@@ -170,7 +165,7 @@ public class TestGravitinoMetalake extends TestBase {CatalogResponse resp = new CatalogResponse(mockCatalog);buildMockResource(Method.GET, path, null, resp, HttpStatus.SC_OK);- Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = gravitinoClient.loadCatalog(catalogName);Assertions.assertEquals(catalogName, catalog.name());Assertions.assertEquals("comment", catalog.comment());@@ -180,10 +175,9 @@ public class TestGravitinoMetalake extends TestBase {ErrorResponse errorResponse =ErrorResponse.notFound(NoSuchCatalogException.class.getSimpleName(), "mock error");buildMockResource(Method.GET, path, null, errorResponse, HttpStatus.SC_NOT_FOUND);- NameIdentifier id = NameIdentifier.of(metalakeName, catalogName);Throwable ex =Assertions.assertThrows(- NoSuchCatalogException.class, () -> gravitinoClient.loadCatalog(id));+ NoSuchCatalogException.class, () -> gravitinoClient.loadCatalog(catalogName));Assertions.assertTrue(ex.getMessage().contains("mock error"));// Test return unsupported catalog type@@ -199,19 +193,21 @@ public class TestGravitinoMetalake extends TestBase {CatalogResponse resp1 = new CatalogResponse(mockCatalog1);buildMockResource(Method.GET, path, null, resp1, HttpStatus.SC_OK);Assertions.assertThrows(- UnsupportedOperationException.class, () -> gravitinoClient.loadCatalog(id));+ UnsupportedOperationException.class, () -> gravitinoClient.loadCatalog(catalogName));// Test return internal errorErrorResponse errorResp = ErrorResponse.internalError("mock error");buildMockResource(Method.GET, path, null, errorResp, HttpStatus.SC_INTERNAL_SERVER_ERROR);Throwable ex1 =- Assertions.assertThrows(RuntimeException.class, () -> gravitinoClient.loadCatalog(id));+ Assertions.assertThrows(+ RuntimeException.class, () -> gravitinoClient.loadCatalog(catalogName));Assertions.assertTrue(ex1.getMessage().contains("mock error"));// Test return unparsed system errorbuildMockResource(Method.GET, path, null, "mock error", HttpStatus.SC_CONFLICT);Throwable ex2 =- Assertions.assertThrows(RESTException.class, () -> gravitinoClient.loadCatalog(id));+ Assertions.assertThrows(+ RESTException.class, () -> gravitinoClient.loadCatalog(catalogName));Assertions.assertTrue(ex2.getMessage().contains("Error code: " + HttpStatus.SC_CONFLICT));}@@ -237,11 +233,7 @@ public class TestGravitinoMetalake extends TestBase {Catalog catalog =gravitinoClient.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- Collections.emptyMap());+ catalogName, Catalog.Type.RELATIONAL, provider, "comment", Collections.emptyMap());Assertions.assertEquals(catalogName, catalog.name());Assertions.assertEquals("comment", catalog.comment());Assertions.assertEquals(Catalog.Type.RELATIONAL, catalog.type());@@ -268,7 +260,7 @@ public class TestGravitinoMetalake extends TestBase {UnsupportedOperationException.class,() ->gravitinoClient.createCatalog(- id, Catalog.Type.MESSAGING, provider, "comment", emptyMap));+ id.name(), Catalog.Type.MESSAGING, provider, "comment", emptyMap));// Test return NoSuchMetalakeExceptionErrorResponse errorResponse =@@ -279,7 +271,7 @@ public class TestGravitinoMetalake extends TestBase {NoSuchMetalakeException.class,() ->gravitinoClient.createCatalog(- id, Catalog.Type.RELATIONAL, provider, "comment", emptyMap));+ id.name(), Catalog.Type.RELATIONAL, provider, "comment", emptyMap));Assertions.assertTrue(ex.getMessage().contains("mock error"));// Test return CatalogAlreadyExistsException@@ -292,7 +284,7 @@ public class TestGravitinoMetalake extends TestBase {CatalogAlreadyExistsException.class,() ->gravitinoClient.createCatalog(- id, Catalog.Type.RELATIONAL, provider, "comment", emptyMap));+ id.name(), Catalog.Type.RELATIONAL, provider, "comment", emptyMap));Assertions.assertTrue(ex1.getMessage().contains("mock error"));// Test return internal error@@ -303,7 +295,7 @@ public class TestGravitinoMetalake extends TestBase {RuntimeException.class,() ->gravitinoClient.createCatalog(- id, Catalog.Type.RELATIONAL, provider, "comment", emptyMap));+ id.name(), Catalog.Type.RELATIONAL, provider, "comment", emptyMap));Assertions.assertTrue(ex2.getMessage().contains("mock error"));}@@ -332,8 +324,7 @@ public class TestGravitinoMetalake extends TestBase {CatalogUpdatesRequest updatesRequest = new CatalogUpdatesRequest(reqs);buildMockResource(Method.PUT, path, updatesRequest, resp, HttpStatus.SC_OK);- NameIdentifier id = NameIdentifier.of(metalakeName, catalogName);- Catalog catalog = gravitinoClient.alterCatalog(id, change1, change2);+ Catalog catalog = gravitinoClient.alterCatalog(catalogName, change1, change2);Assertions.assertEquals("mock1", catalog.name());Assertions.assertEquals("comment1", catalog.comment());Assertions.assertEquals(Catalog.Type.RELATIONAL, catalog.type());@@ -344,7 +335,8 @@ public class TestGravitinoMetalake extends TestBase {buildMockResource(Method.PUT, path, updatesRequest, errorResponse, HttpStatus.SC_NOT_FOUND);Throwable ex =Assertions.assertThrows(- NoSuchCatalogException.class, () -> gravitinoClient.alterCatalog(id, change1, change2));+ NoSuchCatalogException.class,+ () -> gravitinoClient.alterCatalog(catalogName, change1, change2));Assertions.assertTrue(ex.getMessage().contains("mock error"));// Test return IllegalArgumentException@@ -353,7 +345,7 @@ public class TestGravitinoMetalake extends TestBase {Throwable ex1 =Assertions.assertThrows(IllegalArgumentException.class,- () -> gravitinoClient.alterCatalog(id, change1, change2));+ () -> gravitinoClient.alterCatalog(catalogName, change1, change2));Assertions.assertTrue(ex1.getMessage().contains("mock error"));// Test return internal error@@ -362,7 +354,8 @@ public class TestGravitinoMetalake extends TestBase {Method.PUT, path, updatesRequest, errorResp, HttpStatus.SC_INTERNAL_SERVER_ERROR);Throwable ex2 =Assertions.assertThrows(- RuntimeException.class, () -> gravitinoClient.alterCatalog(id, change1, change2));+ RuntimeException.class,+ () -> gravitinoClient.alterCatalog(catalogName, change1, change2));Assertions.assertTrue(ex2.getMessage().contains("mock error"));}@@ -373,13 +366,13 @@ public class TestGravitinoMetalake extends TestBase {DropResponse resp = new DropResponse(true);buildMockResource(Method.DELETE, path, null, resp, HttpStatus.SC_OK);- boolean dropped = gravitinoClient.dropCatalog(NameIdentifier.of(metalakeName, catalogName));+ boolean dropped = gravitinoClient.dropCatalog(catalogName);Assertions.assertTrue(dropped);// Test return falseDropResponse resp1 = new DropResponse(false);buildMockResource(Method.DELETE, path, null, resp1, HttpStatus.SC_OK);- boolean dropped1 = gravitinoClient.dropCatalog(NameIdentifier.of(metalakeName, catalogName));+ boolean dropped1 = gravitinoClient.dropCatalog(catalogName);Assertions.assertFalse(dropped1);}@@ -397,7 +390,6 @@ public class TestGravitinoMetalake extends TestBase {MetalakeResponse resp = new MetalakeResponse(mockMetalake);buildMockResource(Method.POST, "/api/metalakes", req, resp, HttpStatus.SC_OK);- return client.createMetalake(- NameIdentifier.parse(metalakeName), "comment", Collections.emptyMap());+ return client.createMetalake(metalakeName, "comment", Collections.emptyMap());}}diff --git a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestMessagingCatalog.java b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestMessagingCatalog.javaindex 89b8b4050c..0981e1d488 100644--- a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestMessagingCatalog.java+++ b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestMessagingCatalog.java@@ -80,7 +80,7 @@ public class TestMessagingCatalog extends TestBase {catalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,CatalogDTO.Type.MESSAGING,provider,"comment",diff --git a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestRelationalCatalog.java b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestRelationalCatalog.javaindex 4e95b02fee..e6e7f7f374 100644--- a/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestRelationalCatalog.java+++ b/clients/client-java/src/test/java/com/datastrato/gravitino/client/TestRelationalCatalog.java@@ -123,7 +123,7 @@ public class TestRelationalCatalog extends TestBase {catalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,CatalogDTO.Type.RELATIONAL,provider,"comment",diff --git a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.javaindex 462e2faa6f..92f0152cac 100644--- a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java+++ b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java@@ -378,8 +378,7 @@ public class GravitinoVirtualFileSystem extends FileSystem {}private Fileset loadFileset(NameIdentifier identifier) {- Catalog catalog =- client.loadCatalog(NameIdentifier.ofCatalog(metalakeName, identifier.namespace().level(1)));+ Catalog catalog = client.loadCatalog(identifier.namespace().level(1));return catalog.asFilesetCatalog().loadFileset(identifier);}diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogDispatcher.javaindex a1d4d4031b..38b4fda496 100644--- a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogDispatcher.java+++ b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogDispatcher.java@@ -5,8 +5,6 @@package com.datastrato.gravitino.catalog;-import com.datastrato.gravitino.SupportsCatalogs;-/*** {@code CatalogDispatcher} interface acts as a specialization of the {@link SupportsCatalogs}* interface. This interface is designed to potentially add custom behaviors or operations relateddiff --git a/api/src/main/java/com/datastrato/gravitino/SupportsCatalogs.java b/core/src/main/java/com/datastrato/gravitino/catalog/SupportsCatalogs.javasimilarity index 93%rename from api/src/main/java/com/datastrato/gravitino/SupportsCatalogs.javarename to core/src/main/java/com/datastrato/gravitino/catalog/SupportsCatalogs.javaindex d6e36aa883..c1ce8cb586 100644--- a/api/src/main/java/com/datastrato/gravitino/SupportsCatalogs.java+++ b/core/src/main/java/com/datastrato/gravitino/catalog/SupportsCatalogs.java@@ -2,8 +2,13 @@* Copyright 2023 Datastrato Pvt Ltd.* This software is licensed under the Apache License version 2.*/-package com.datastrato.gravitino;+package com.datastrato.gravitino.catalog;+import com.datastrato.gravitino.Catalog;+import com.datastrato.gravitino.CatalogChange;+import com.datastrato.gravitino.CatalogProvider;+import com.datastrato.gravitino.NameIdentifier;+import com.datastrato.gravitino.Namespace;import com.datastrato.gravitino.annotation.Evolving;import com.datastrato.gravitino.exceptions.CatalogAlreadyExistsException;import com.datastrato.gravitino.exceptions.NoSuchCatalogException;diff --git a/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeDispatcher.java b/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeDispatcher.javaindex c7848326a1..645c722029 100644--- a/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeDispatcher.java+++ b/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeDispatcher.java@@ -5,8 +5,6 @@package com.datastrato.gravitino.metalake;-import com.datastrato.gravitino.SupportsMetalakes;-/*** {@code MetalakeDispatcher} interface acts as a specialization of the {@link SupportsMetalakes}* interface. This interface is designed to potentially add custom behaviors or operations relateddiff --git a/api/src/main/java/com/datastrato/gravitino/SupportsMetalakes.java b/core/src/main/java/com/datastrato/gravitino/metalake/SupportsMetalakes.javasimilarity index 93%rename from api/src/main/java/com/datastrato/gravitino/SupportsMetalakes.javarename to core/src/main/java/com/datastrato/gravitino/metalake/SupportsMetalakes.javaindex 14df602447..664f60e3f0 100644--- a/api/src/main/java/com/datastrato/gravitino/SupportsMetalakes.java+++ b/core/src/main/java/com/datastrato/gravitino/metalake/SupportsMetalakes.java@@ -2,8 +2,11 @@* Copyright 2023 Datastrato Pvt Ltd.* This software is licensed under the Apache License version 2.*/-package com.datastrato.gravitino;+package com.datastrato.gravitino.metalake;+import com.datastrato.gravitino.Metalake;+import com.datastrato.gravitino.MetalakeChange;+import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.annotation.Evolving;import com.datastrato.gravitino.exceptions.MetalakeAlreadyExistsException;import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/AuditIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/AuditIT.javaindex 45d548e6b5..d99d2d154e 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/AuditIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/AuditIT.java@@ -7,7 +7,6 @@ package com.datastrato.gravitino.integration.test.client;import com.datastrato.gravitino.Configs;import com.datastrato.gravitino.MetalakeChange;-import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.auth.AuthenticatorType;import com.datastrato.gravitino.client.GravitinoMetalake;import com.datastrato.gravitino.integration.test.util.AbstractIT;@@ -37,17 +36,16 @@ public class AuditIT extends AbstractIT {String newName = RandomNameUtils.genRandomName("newmetaname");GravitinoMetalake metaLake =- client.createMetalake(- NameIdentifier.parse(metalakeAuditName), "metalake A comment", Collections.emptyMap());+ client.createMetalake(metalakeAuditName, "metalake A comment", Collections.emptyMap());Assertions.assertEquals(expectUser, metaLake.auditInfo().creator());Assertions.assertNull(metaLake.auditInfo().lastModifier());MetalakeChange[] changes =new MetalakeChange[] {MetalakeChange.rename(newName), MetalakeChange.updateComment("new metalake comment")};- metaLake = client.alterMetalake(NameIdentifier.of(metalakeAuditName), changes);+ metaLake = client.alterMetalake(metalakeAuditName, changes);Assertions.assertEquals(expectUser, metaLake.auditInfo().creator());Assertions.assertEquals(expectUser, metaLake.auditInfo().lastModifier());- client.dropMetalake(NameIdentifier.parse(newName));+ client.dropMetalake(newName);}}diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.javaindex 451986eeea..e11f9252ef 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.java@@ -6,7 +6,6 @@package com.datastrato.gravitino.integration.test.client;import com.datastrato.gravitino.Catalog;-import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.client.GravitinoMetalake;import com.datastrato.gravitino.integration.test.container.ContainerSuite;import com.datastrato.gravitino.integration.test.container.HiveContainer;@@ -48,15 +47,14 @@ public class CatalogIT extends AbstractIT {containerSuite.getHiveContainer().getContainerIpAddress(),HiveContainer.HIVE_METASTORE_PORT);- NameIdentifier ident = NameIdentifier.of(metalakeName);- Assertions.assertFalse(client.metalakeExists(ident));- metalake = client.createMetalake(ident, "metalake comment", Collections.emptyMap());- Assertions.assertTrue(client.metalakeExists(ident));+ Assertions.assertFalse(client.metalakeExists(metalakeName));+ metalake = client.createMetalake(metalakeName, "metalake comment", Collections.emptyMap());+ Assertions.assertTrue(client.metalakeExists(metalakeName));}@AfterAllpublic static void tearDown() {- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);if (client != null) {client.close();@@ -73,15 +71,14 @@ public class CatalogIT extends AbstractIT {@Testpublic void testCreateCatalog() {String catalogName = GravitinoITUtils.genRandomName("catalog");- NameIdentifier catalogIdent = NameIdentifier.of(metalakeName, catalogName);- Assertions.assertFalse(metalake.catalogExists(catalogIdent));+ Assertions.assertFalse(metalake.catalogExists(catalogName));Map<String, String> properties = Maps.newHashMap();properties.put("metastore.uris", hmsUri);Catalog catalog =metalake.createCatalog(- catalogIdent, Catalog.Type.RELATIONAL, "hive", "catalog comment", properties);- Assertions.assertTrue(metalake.catalogExists(catalogIdent));+ catalogName, Catalog.Type.RELATIONAL, "hive", "catalog comment", properties);+ Assertions.assertTrue(metalake.catalogExists(catalogName));Assertions.assertEquals(catalogName, catalog.name());Assertions.assertEquals(Catalog.Type.RELATIONAL, catalog.type());@@ -89,19 +86,18 @@ public class CatalogIT extends AbstractIT {Assertions.assertEquals("catalog comment", catalog.comment());Assertions.assertTrue(catalog.properties().containsKey("metastore.uris"));- metalake.dropCatalog(catalogIdent);+ metalake.dropCatalog(catalogName);}@Testpublic void testCreateCatalogWithoutProperties() {String catalogName = GravitinoITUtils.genRandomName("catalog");- NameIdentifier catalogIdent = NameIdentifier.of(metalakeName, catalogName);- Assertions.assertFalse(metalake.catalogExists(catalogIdent));+ Assertions.assertFalse(metalake.catalogExists(catalogName));Catalog catalog =metalake.createCatalog(- catalogIdent, Catalog.Type.FILESET, "hadoop", "catalog comment", null);- Assertions.assertTrue(metalake.catalogExists(catalogIdent));+ catalogName, Catalog.Type.FILESET, "hadoop", "catalog comment", null);+ Assertions.assertTrue(metalake.catalogExists(catalogName));Assertions.assertEquals(catalogName, catalog.name());Assertions.assertEquals(Catalog.Type.FILESET, catalog.type());@@ -109,55 +105,51 @@ public class CatalogIT extends AbstractIT {Assertions.assertEquals("catalog comment", catalog.comment());Assertions.assertTrue(catalog.properties().isEmpty());- metalake.dropCatalog(catalogIdent);+ metalake.dropCatalog(catalogName);}@Testpublic void testCreateCatalogWithChinese() {String catalogName = GravitinoITUtils.genRandomName("catalogz");- NameIdentifier catalogIdent = NameIdentifier.of(metalakeName, catalogName);- Assertions.assertFalse(metalake.catalogExists(catalogIdent));+ Assertions.assertFalse(metalake.catalogExists(catalogName));Map<String, String> properties = Maps.newHashMap();properties.put("metastore.uris", hmsUri);- metalake.createCatalog(- catalogIdent, Catalog.Type.RELATIONAL, "hive", "这是中文comment", properties);- Assertions.assertTrue(metalake.catalogExists(catalogIdent));- Catalog catalog = metalake.loadCatalog(catalogIdent);+ metalake.createCatalog(catalogName, Catalog.Type.RELATIONAL, "hive", "这是中文comment", properties);+ Assertions.assertTrue(metalake.catalogExists(catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(catalogName, catalog.name());Assertions.assertEquals(Catalog.Type.RELATIONAL, catalog.type());Assertions.assertEquals("hive", catalog.provider());Assertions.assertEquals("这是中文comment", catalog.comment());Assertions.assertTrue(catalog.properties().containsKey("metastore.uris"));- metalake.dropCatalog(catalogIdent);+ metalake.dropCatalog(catalogName);}@Testpublic void testListCatalogsInfo() {String relCatalogName = GravitinoITUtils.genRandomName("rel_catalog_");- NameIdentifier relCatalogIdent = NameIdentifier.of(metalakeName, relCatalogName);Map<String, String> properties = Maps.newHashMap();properties.put("metastore.uris", hmsUri);Catalog relCatalog =metalake.createCatalog(- relCatalogIdent,+ relCatalogName,Catalog.Type.RELATIONAL,"hive","relational catalog comment",properties);String fileCatalogName = GravitinoITUtils.genRandomName("file_catalog_");- NameIdentifier fileCatalogIdent = NameIdentifier.of(metalakeName, fileCatalogName);Catalog fileCatalog =metalake.createCatalog(- fileCatalogIdent,+ fileCatalogName,Catalog.Type.FILESET,"hadoop","file catalog comment",Collections.emptyMap());- Catalog[] catalogs = metalake.listCatalogsInfo(relCatalogIdent.namespace());+ Catalog[] catalogs = metalake.listCatalogsInfo();for (Catalog catalog : catalogs) {if (catalog.name().equals(relCatalogName)) {assertCatalogEquals(relCatalog, catalog);@@ -180,8 +172,7 @@ public class CatalogIT extends AbstractIT {@DisabledIfSystemProperty(named = "testMode", matches = "embedded")public void testCreateCatalogWithPackage() {String catalogName = GravitinoITUtils.genRandomName("catalog");- NameIdentifier catalogIdent = NameIdentifier.of(metalakeName, catalogName);- Assertions.assertFalse(metalake.catalogExists(catalogIdent));+ Assertions.assertFalse(metalake.catalogExists(catalogName));Map<String, String> properties = Maps.newHashMap();properties.put("metastore.uris", hmsUri);@@ -193,8 +184,8 @@ public class CatalogIT extends AbstractIT {Catalog catalog =metalake.createCatalog(- catalogIdent, Catalog.Type.RELATIONAL, "hive", "catalog comment", properties);- Assertions.assertTrue(metalake.catalogExists(catalogIdent));+ catalogName, Catalog.Type.RELATIONAL, "hive", "catalog comment", properties);+ Assertions.assertTrue(metalake.catalogExists(catalogName));Assertions.assertEquals(catalogName, catalog.name());Assertions.assertEquals(Catalog.Type.RELATIONAL, catalog.type());@@ -202,18 +193,17 @@ public class CatalogIT extends AbstractIT {Assertions.assertEquals("catalog comment", catalog.comment());Assertions.assertTrue(catalog.properties().containsKey("package"));- metalake.dropCatalog(catalogIdent);+ metalake.dropCatalog(catalogName);// Test using invalid package pathString catalogName1 = GravitinoITUtils.genRandomName("catalog");- NameIdentifier catalogIdent1 = NameIdentifier.of(metalakeName, catalogName1);properties.put("package", "/tmp/none_exist_path_to_package");Exception exception =Assertions.assertThrows(IllegalArgumentException.class,() ->metalake.createCatalog(- catalogIdent1, Catalog.Type.RELATIONAL, "hive", "catalog comment", properties));+ catalogName1, Catalog.Type.RELATIONAL, "hive", "catalog comment", properties));Assertions.assertTrue(exception.getMessage().contains("Invalid package path: /tmp/none_exist_path_to_package"));}diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.javaindex d51f53029b..33eda2fbc1 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.java@@ -13,8 +13,6 @@ import com.datastrato.gravitino.MetalakeChange;import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.auth.AuthConstants;import com.datastrato.gravitino.client.GravitinoMetalake;-import com.datastrato.gravitino.exceptions.IllegalNameIdentifierException;-import com.datastrato.gravitino.exceptions.IllegalNamespaceException;import com.datastrato.gravitino.exceptions.MetalakeAlreadyExistsException;import com.datastrato.gravitino.exceptions.NoSuchMetalakeException;import com.datastrato.gravitino.integration.test.util.AbstractIT;@@ -52,15 +50,13 @@ public class MetalakeIT extends AbstractIT {assertEquals(0, metaLakes.length);// one metalakes- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "metalake A comment", Collections.emptyMap());+ client.createMetalake(metalakeNameA, "metalake A comment", Collections.emptyMap());metaLakes = client.listMetalakes();assertEquals(1, metaLakes.length);assertEquals(metaLakes[0].name(), metalakeNameA);// two metalakes- client.createMetalake(- NameIdentifier.parse(metalakeNameB), "metalake B comment", Collections.emptyMap());+ client.createMetalake(metalakeNameB, "metalake B comment", Collections.emptyMap());metaLakes = client.listMetalakes();ArrayList<String> names = new ArrayList<>(2);assertEquals(2, metaLakes.length);@@ -73,9 +69,8 @@ public class MetalakeIT extends AbstractIT {@Testpublic void testLoadMetalake() {// metalake exists- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "metalake A comment", Collections.emptyMap());- GravitinoMetalake metaLakeA = client.loadMetalake(NameIdentifier.of(metalakeNameA));+ client.createMetalake(metalakeNameA, "metalake A comment", Collections.emptyMap());+ GravitinoMetalake metaLakeA = client.loadMetalake(metalakeNameA);assertEquals(metaLakeA.name(), metalakeNameA);// metalake does not exist@@ -83,50 +78,43 @@ public class MetalakeIT extends AbstractIT {assertThrows(NoSuchMetalakeException.class,() -> {- client.loadMetalake(noexist);+ client.loadMetalake(noexist.name());});// metalake empty name - note it's NameIdentifier.of("") that fails not the load- assertThrows(- IllegalNameIdentifierException.class, () -> client.loadMetalake(NameIdentifier.of("")));-- // metalake bad name- NameIdentifier abc = NameIdentifier.of("A", "B", "C");- assertThrows(IllegalNamespaceException.class, () -> client.loadMetalake(abc));+ assertThrows(IllegalArgumentException.class, () -> client.loadMetalake(""));}@Testpublic void testAlterMetalake() {String newName = RandomNameUtils.genRandomName("newmetaname");- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "metalake A comment", Collections.emptyMap());+ client.createMetalake(metalakeNameA, "metalake A comment", Collections.emptyMap());MetalakeChange[] changes =new MetalakeChange[] {MetalakeChange.rename(newName), MetalakeChange.updateComment("new metalake comment")};- GravitinoMetalake metaLake = client.alterMetalake(NameIdentifier.of(metalakeNameA), changes);+ GravitinoMetalake metaLake = client.alterMetalake(metalakeNameA, changes);assertEquals(newName, metaLake.name());assertEquals("new metalake comment", metaLake.comment());assertEquals(AuthConstants.ANONYMOUS_USER, metaLake.auditInfo().creator());// Reload metadata via new name to check if the changes are applied- GravitinoMetalake newMetalake = client.loadMetalake(NameIdentifier.of(newName));+ GravitinoMetalake newMetalake = client.loadMetalake(newName);assertEquals(newName, newMetalake.name());assertEquals("new metalake comment", newMetalake.comment());// Old name does not existNameIdentifier old = NameIdentifier.of(metalakeNameA);- assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(old));+ assertThrows(NoSuchMetalakeException.class, () -> client.loadMetalake(old.name()));}@Testpublic void testAlterNonExistentMetalake() {String newName = RandomNameUtils.genRandomName("newmetaname");- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "metalake A comment", Collections.emptyMap());+ client.createMetalake(metalakeNameA, "metalake A comment", Collections.emptyMap());MetalakeChange[] changes =new MetalakeChange[] {@@ -135,14 +123,14 @@ public class MetalakeIT extends AbstractIT {// rename non existent metalakeNameIdentifier noexists = NameIdentifier.of(metalakeNameB);- assertThrows(NoSuchMetalakeException.class, () -> client.alterMetalake(noexists, changes));+ assertThrows(+ NoSuchMetalakeException.class, () -> client.alterMetalake(noexists.name(), changes));}@Testpublic void testCreateMetalake() {- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "metalake A comment", Collections.emptyMap());- GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeNameA));+ client.createMetalake(metalakeNameA, "metalake A comment", Collections.emptyMap());+ GravitinoMetalake metalake = client.loadMetalake(metalakeNameA);assertEquals(metalakeNameA, metalake.name());assertEquals("metalake A comment", metalake.comment());assertEquals(AuthConstants.ANONYMOUS_USER, metalake.auditInfo().creator());@@ -153,15 +141,14 @@ public class MetalakeIT extends AbstractIT {assertThrows(MetalakeAlreadyExistsException.class,() -> {- client.createMetalake(exists, "metalake A comment", emptyMap);+ client.createMetalake(exists.name(), "metalake A comment", emptyMap);});}@Testpublic void testCreateMetalakeWithChinese() {- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "这是中文comment", Collections.emptyMap());- GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeNameA));+ client.createMetalake(metalakeNameA, "这是中文comment", Collections.emptyMap());+ GravitinoMetalake metalake = client.loadMetalake(metalakeNameA);assertEquals(metalakeNameA, metalake.name());assertEquals("这是中文comment", metalake.comment());assertEquals(AuthConstants.ANONYMOUS_USER, metalake.auditInfo().creator());@@ -172,39 +159,30 @@ public class MetalakeIT extends AbstractIT {assertThrows(MetalakeAlreadyExistsException.class,() -> {- client.createMetalake(exists, "metalake A comment", emptyMap);+ client.createMetalake(exists.name(), "metalake A comment", emptyMap);});}@Testpublic void testDropMetalakes() {GravitinoMetalake metalakeA =- client.createMetalake(- NameIdentifier.parse(metalakeNameA), "metalake A comment", Collections.emptyMap());- assertTrue(client.dropMetalake(NameIdentifier.of(metalakeA.name())));+ client.createMetalake(metalakeNameA, "metalake A comment", Collections.emptyMap());+ assertTrue(client.dropMetalake(metalakeA.name()));NameIdentifier id = NameIdentifier.of(metalakeNameA);assertThrows(NoSuchMetalakeException.class,() -> {- client.loadMetalake(id);+ client.loadMetalake(id.name());});// Metalake does not exist, so we return false- assertFalse(client.dropMetalake(NameIdentifier.of(metalakeA.name())));-- // Bad metalake name- NameIdentifier badname = NameIdentifier.of("A", "B");- assertThrows(- IllegalNamespaceException.class,- () -> {- client.dropMetalake(badname);- });+ assertFalse(client.dropMetalake(metalakeA.name()));}public void dropMetalakes() {GravitinoMetalake[] metaLakes = client.listMetalakes();for (GravitinoMetalake metalake : metaLakes) {- assertTrue(client.dropMetalake(NameIdentifier.of(metalake.name())));+ assertTrue(client.dropMetalake(metalake.name()));}// Reload metadata from backend to check if the drop operations are applied@@ -213,12 +191,12 @@ public class MetalakeIT extends AbstractIT {Assertions.assertThrows(NoSuchMetalakeException.class,() -> {- client.loadMetalake(id);+ client.loadMetalake(id.name());});}for (GravitinoMetalake metalake : metaLakes) {- Assertions.assertFalse(client.dropMetalake(NameIdentifier.of(metalake.name())));+ Assertions.assertFalse(client.dropMetalake(metalake.name()));}}}diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.javaindex 298f8dd8fb..d3c5c246e3 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java@@ -52,17 +52,15 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {@BeforeAllpublic static void startUp() {containerSuite.startHiveContainer();- NameIdentifier ident = NameIdentifier.of(metalakeName);- Assertions.assertFalse(client.metalakeExists(ident));- metalake = client.createMetalake(ident, "metalake comment", Collections.emptyMap());- Assertions.assertTrue(client.metalakeExists(ident));+ Assertions.assertFalse(client.metalakeExists(metalakeName));+ metalake = client.createMetalake(metalakeName, "metalake comment", Collections.emptyMap());+ Assertions.assertTrue(client.metalakeExists(metalakeName));- NameIdentifier catalogIdent = NameIdentifier.of(metalakeName, catalogName);Map<String, String> properties = Maps.newHashMap();Catalog catalog =metalake.createCatalog(- catalogIdent, Catalog.Type.FILESET, "hadoop", "catalog comment", properties);- Assertions.assertTrue(metalake.catalogExists(catalogIdent));+ catalogName, Catalog.Type.FILESET, "hadoop", "catalog comment", properties);+ Assertions.assertTrue(metalake.catalogExists(catalogName));NameIdentifier schemaIdent = NameIdentifier.of(metalakeName, catalogName, schemaName);catalog.asSchemas().createSchema(schemaIdent, "schema comment", properties);@@ -78,7 +76,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {@AfterAllpublic static void tearDown() throws IOException {- client.dropMetalake(NameIdentifier.of(metalakeName));+ client.dropMetalake(metalakeName);if (client != null) {client.close();@@ -105,7 +103,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_create";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()@@ -140,7 +138,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_append";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()@@ -200,7 +198,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_delete";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()@@ -240,7 +238,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_get_status";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()@@ -283,7 +281,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_list_status";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()@@ -340,7 +338,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_mkdirs";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()@@ -375,7 +373,7 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {String filesetName = "test_fileset_rename";NameIdentifier filesetIdent =NameIdentifier.ofFileset(metalakeName, catalogName, schemaName, filesetName);- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);String storageLocation = genStorageLocation(filesetName);catalog.asFilesetCatalog()diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/spark/SparkEnvIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/spark/SparkEnvIT.javaindex 7094434cbb..ea3193c8a2 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/spark/SparkEnvIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/spark/SparkEnvIT.java@@ -6,7 +6,6 @@package com.datastrato.gravitino.integration.test.spark;import com.datastrato.gravitino.Catalog;-import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.auxiliary.AuxiliaryServiceManager;import com.datastrato.gravitino.client.GravitinoMetalake;import com.datastrato.gravitino.integration.test.container.ContainerSuite;@@ -103,15 +102,11 @@ public abstract class SparkEnvIT extends SparkUtilIT {public static void stopIntegrationTest() {}private void initMetalakeAndCatalogs() {- client.createMetalake(NameIdentifier.of(metalakeName), "", Collections.emptyMap());- GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "", Collections.emptyMap());+ GravitinoMetalake metalake = client.loadMetalake(metalakeName);Map<String, String> properties = getCatalogConfigs();metalake.createCatalog(- NameIdentifier.of(metalakeName, getCatalogName()),- Catalog.Type.RELATIONAL,- getProvider(),- "",- properties);+ getCatalogName(), Catalog.Type.RELATIONAL, getProvider(), "", properties);}private void initGravitinoEnv() {diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.javaindex 52d3075e40..bc130b9b31 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java@@ -441,10 +441,10 @@ public class TrinoConnectorIT extends AbstractIT {String catalogName = GravitinoITUtils.genRandomName("catalog").toLowerCase();String schemaName = GravitinoITUtils.genRandomName("schema").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);Catalog catalog =createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"hive","comment",@@ -590,7 +590,7 @@ public class TrinoConnectorIT extends AbstractIT {@Testvoid testColumnTypeNotNullByTrino() {String catalogName = GravitinoITUtils.genRandomName("mysql_catalog").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String[] command = {"mysql","-h127.0.0.1",@@ -605,7 +605,7 @@ public class TrinoConnectorIT extends AbstractIT {String hiveHost = containerSuite.getHiveContainer().getContainerIpAddress();createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"jdbc-mysql","comment",@@ -683,10 +683,10 @@ public class TrinoConnectorIT extends AbstractIT {String schemaName = GravitinoITUtils.genRandomName("schema").toLowerCase();String tableName = GravitinoITUtils.genRandomName("table").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);Catalog catalog =createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"hive","comment",@@ -818,9 +818,9 @@ public class TrinoConnectorIT extends AbstractIT {@Testvoid testHiveCatalogCreatedByGravitino() {String catalogName = GravitinoITUtils.genRandomName("catalog").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"hive","comment",@@ -836,7 +836,7 @@ public class TrinoConnectorIT extends AbstractIT {.put("trino.bypass.hive.create-empty-bucket-files", "true").put("trino.bypass.hive.validate-bucketing", "true").build());- Catalog catalog = createdMetalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = createdMetalake.loadCatalog(catalogName);Assertions.assertEquals("true", catalog.properties().get("trino.bypass.hive.immutable-partitions"));Assertions.assertEquals(@@ -860,9 +860,9 @@ public class TrinoConnectorIT extends AbstractIT {@Testvoid testWrongHiveCatalogProperty() {String catalogName = GravitinoITUtils.genRandomName("catalog").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"hive","comment",@@ -879,7 +879,7 @@ public class TrinoConnectorIT extends AbstractIT {.put("trino.bypass.hive.create-empty-bucket-files", "true").put("trino.bypass.hive.validate-bucketing", "true").build());- Catalog catalog = createdMetalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = createdMetalake.loadCatalog(catalogName);Assertions.assertEquals("true", catalog.properties().get("trino.bypass.hive.immutable-partitions"));Assertions.assertEquals(@@ -902,11 +902,11 @@ public class TrinoConnectorIT extends AbstractIT {String schemaName = GravitinoITUtils.genRandomName("schema").toLowerCase();String tableName = GravitinoITUtils.genRandomName("table").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String hiveContainerIp = containerSuite.getHiveContainer().getContainerIpAddress();Catalog catalog =createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"lakehouse-iceberg","comment",@@ -1015,7 +1015,7 @@ public class TrinoConnectorIT extends AbstractIT {void testIcebergCatalogCreatedByGravitino() {String catalogName = GravitinoITUtils.genRandomName("iceberg_catalog").toLowerCase();String schemaName = GravitinoITUtils.genRandomName("iceberg_catalog").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String[] command = {"mysql","-h127.0.0.1",@@ -1030,7 +1030,7 @@ public class TrinoConnectorIT extends AbstractIT {String hiveHost = containerSuite.getHiveContainer().getContainerIpAddress();createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"lakehouse-iceberg","comment",@@ -1045,7 +1045,7 @@ public class TrinoConnectorIT extends AbstractIT {.put("jdbc-password", "ds123").put("jdbc-driver", "com.mysql.cj.jdbc.Driver").build());- Catalog catalog = createdMetalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = createdMetalake.loadCatalog(catalogName);Assertions.assertEquals("root", catalog.properties().get("jdbc-user"));String sql = String.format("show catalogs like '%s'", catalogName);@@ -1098,7 +1098,7 @@ public class TrinoConnectorIT extends AbstractIT {@Testvoid testMySQLCatalogCreatedByGravitino() {String catalogName = GravitinoITUtils.genRandomName("mysql_catalog").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String[] command = {"mysql","-h127.0.0.1",@@ -1113,7 +1113,7 @@ public class TrinoConnectorIT extends AbstractIT {String hiveHost = containerSuite.getHiveContainer().getContainerIpAddress();createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"jdbc-mysql","comment",@@ -1123,7 +1123,7 @@ public class TrinoConnectorIT extends AbstractIT {.put("jdbc-password", "ds123").put("jdbc-url", String.format("jdbc:mysql://%s:3306?useSSL=false", hiveHost)).build());- Catalog catalog = createdMetalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = createdMetalake.loadCatalog(catalogName);Assertions.assertEquals("root", catalog.properties().get("jdbc-user"));String sql = String.format("show catalogs like '%s'", catalogName);@@ -1141,7 +1141,7 @@ public class TrinoConnectorIT extends AbstractIT {String catalogName = GravitinoITUtils.genRandomName("mysql_catalog").toLowerCase();String schemaName = GravitinoITUtils.genRandomName("mysql_schema").toLowerCase();String tableName = GravitinoITUtils.genRandomName("mysql_table").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String[] command = {"mysql","-h127.0.0.1",@@ -1156,7 +1156,7 @@ public class TrinoConnectorIT extends AbstractIT {String hiveHost = containerSuite.getHiveContainer().getContainerIpAddress();createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"jdbc-mysql","comment",@@ -1166,7 +1166,7 @@ public class TrinoConnectorIT extends AbstractIT {.put("jdbc-password", "ds123").put("jdbc-url", String.format("jdbc:mysql://%s:3306?useSSL=false", hiveHost)).build());- Catalog catalog = createdMetalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = createdMetalake.loadCatalog(catalogName);Assertions.assertEquals("root", catalog.properties().get("jdbc-user"));String sql = String.format("show catalogs like '%s'", catalogName);@@ -1255,7 +1255,7 @@ public class TrinoConnectorIT extends AbstractIT {String catalogName = GravitinoITUtils.genRandomName("mysql_catalog").toLowerCase();String schemaName = GravitinoITUtils.genRandomName("mysql_schema").toLowerCase();String tableName = GravitinoITUtils.genRandomName("mysql_table").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String[] command = {"mysql","-h127.0.0.1",@@ -1270,7 +1270,7 @@ public class TrinoConnectorIT extends AbstractIT {String hiveHost = containerSuite.getHiveContainer().getContainerIpAddress();createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"jdbc-mysql","comment",@@ -1280,7 +1280,7 @@ public class TrinoConnectorIT extends AbstractIT {.put("jdbc-password", "ds123").put("jdbc-url", String.format("jdbc:mysql://%s:3306?useSSL=false", hiveHost)).build());- Catalog catalog = createdMetalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = createdMetalake.loadCatalog(catalogName);Assertions.assertEquals("root", catalog.properties().get("jdbc-user"));String sql = String.format("show catalogs like '%s'", catalogName);@@ -1375,7 +1375,7 @@ public class TrinoConnectorIT extends AbstractIT {@Testvoid testDropCatalogAndCreateAgain() {String catalogName = GravitinoITUtils.genRandomName("mysql_catalog").toLowerCase();- GravitinoMetalake createdMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ GravitinoMetalake createdMetalake = client.loadMetalake(metalakeName);String[] command = {"mysql","-h127.0.0.1",@@ -1393,7 +1393,7 @@ public class TrinoConnectorIT extends AbstractIT {// well.for (int i = 0; i < 3; i++) {createdMetalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),+ catalogName,Catalog.Type.RELATIONAL,"jdbc-mysql","comment",@@ -1408,7 +1408,7 @@ public class TrinoConnectorIT extends AbstractIT {boolean success = checkTrinoHasLoaded(sql, 30);Assertions.assertTrue(success, "Trino should load the catalog: " + sql);- createdMetalake.dropCatalog(NameIdentifier.of(metalakeName, catalogName));+ createdMetalake.dropCatalog(catalogName);// We need to test we can't load this catalog any more by Trino.success = checkTrinoHasRemoved(sql, 30);Assertions.assertTrue(success, "Trino should not load the catalog any more: " + sql);@@ -1420,8 +1420,8 @@ public class TrinoConnectorIT extends AbstractIT {Assertions.assertEquals(0, gravitinoMetalakes.length);GravitinoMetalake createdMetalake =- client.createMetalake(NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());- GravitinoMetalake loadMetalake = client.loadMetalake(NameIdentifier.of(metalakeName));+ client.createMetalake(metalakeName, "comment", Collections.emptyMap());+ GravitinoMetalake loadMetalake = client.loadMetalake(metalakeName);Assertions.assertEquals(createdMetalake, loadMetalake);metalake = loadMetalake;@@ -1438,13 +1438,8 @@ public class TrinoConnectorIT extends AbstractIT {properties.put("metastore.uris", hiveMetastoreUris);Catalog createdCatalog =- metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- "hive",- "comment",- properties);- Catalog loadCatalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ metalake.createCatalog(catalogName, Catalog.Type.RELATIONAL, "hive", "comment", properties);+ Catalog loadCatalog = metalake.loadCatalog(catalogName);Assertions.assertEquals(createdCatalog, loadCatalog);catalog = loadCatalog;diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.javaindex e071cc7a51..312aefcdd4 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryIT.java@@ -6,7 +6,6 @@ package com.datastrato.gravitino.integration.test.trino;import static org.testcontainers.shaded.org.awaitility.Awaitility.await;-import com.datastrato.gravitino.Namespace;import com.datastrato.gravitino.integration.test.util.ITUtils;import java.io.FileOutputStream;import java.io.IOException;@@ -79,7 +78,7 @@ public class TrinoQueryIT extends TrinoQueryITBase {private static void cleanupTestEnv() throws Exception {try {- Arrays.stream(TrinoQueryITBase.metalake.listCatalogs(Namespace.of(metalakeName)))+ Arrays.stream(TrinoQueryITBase.metalake.listCatalogs()).filter(catalog -> catalog.name().startsWith("gt_")).forEach(catalog -> TrinoQueryITBase.dropCatalog(catalog.name()));diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryITBase.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryITBase.javaindex ed9561dca6..282b3d595c 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryITBase.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoQueryITBase.java@@ -111,16 +111,15 @@ public class TrinoQueryITBase {int tries = 180;while (!created && tries-- >= 0) {try {- boolean exists = gravitinoClient.metalakeExists(NameIdentifier.of(metalakeName));+ boolean exists = gravitinoClient.metalakeExists(metalakeName);if (exists) {- metalake = gravitinoClient.loadMetalake(NameIdentifier.of(metalakeName));+ metalake = gravitinoClient.loadMetalake(metalakeName);return;}GravitinoMetalake createdMetalake =- gravitinoClient.createMetalake(- NameIdentifier.of(metalakeName), "comment", Collections.emptyMap());+ gravitinoClient.createMetalake(metalakeName, "comment", Collections.emptyMap());Assertions.assertNotNull(createdMetalake);metalake = createdMetalake;created = true;@@ -136,24 +135,20 @@ public class TrinoQueryITBase {}private static void dropMetalake() {- boolean exists = gravitinoClient.metalakeExists(NameIdentifier.of(metalakeName));+ boolean exists = gravitinoClient.metalakeExists(metalakeName);if (!exists) {return;}- gravitinoClient.dropMetalake(NameIdentifier.of(metalakeName));+ gravitinoClient.dropMetalake(metalakeName);}private static void createCatalog(String catalogName, String provider, Map<String, String> properties) throws Exception {- boolean exists = metalake.catalogExists(NameIdentifier.of(metalakeName, catalogName));+ boolean exists = metalake.catalogExists(catalogName);if (!exists) {Catalog createdCatalog =metalake.createCatalog(- NameIdentifier.of(metalakeName, catalogName),- Catalog.Type.RELATIONAL,- provider,- "comment",- properties);+ catalogName, Catalog.Type.RELATIONAL, provider, "comment", properties);Assertions.assertNotNull(createdCatalog);}@@ -183,11 +178,11 @@ public class TrinoQueryITBase {if (metalake == null) {return;}- boolean exists = metalake.catalogExists(NameIdentifier.of(metalakeName, catalogName));+ boolean exists = metalake.catalogExists(catalogName);if (!exists) {return;}- Catalog catalog = metalake.loadCatalog(NameIdentifier.of(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);SupportsSchemas schemas = catalog.asSchemas();Arrays.stream(schemas.listSchemas(Namespace.ofSchema(metalakeName, catalogName))).filter(schema -> schema.name().startsWith("gt_"))@@ -223,7 +218,7 @@ public class TrinoQueryITBase {LOG.info("Drop schema \"{}.{}\".{}", metalakeName, catalogName, schema.name());});- metalake.dropCatalog(NameIdentifier.of(metalakeName, catalogName));+ metalake.dropCatalog(catalogName);LOG.info("Drop catalog \"{}.{}\"", metalakeName, catalogName);}diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageDorisTest.javaindex 0e32e685db..2e47f35f3f 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageDorisTest.java@@ -102,8 +102,7 @@ public class CatalogsPageDorisTest extends AbstractWebIT {void createSchema(String metalakeName, String catalogName, String schemaName) {Map<String, String> properties = Maps.newHashMap();properties.put(PROPERTIES_KEY1, PROPERTIES_VALUE1);- Catalog catalog_doris =- metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog_doris = metalake.loadCatalog(catalogName);catalog_doris.asSchemas().createSchema(@@ -128,8 +127,7 @@ public class CatalogsPageDorisTest extends AbstractWebIT {Map<String, String> properties = Maps.newHashMap();properties.put("replication_allocation", "tag.location.default: 1");Column column = Column.of(colName, Types.IntegerType.get(), "column comment");- Catalog catalog_doris =- metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog_doris = metalake.loadCatalog(catalogName);catalog_doris.asTableCatalog().createTable(@@ -149,7 +147,7 @@ public class CatalogsPageDorisTest extends AbstractWebIT {metalakePage.setMetalakeNameField(METALAKE_NAME);clickAndWait(metalakePage.submitHandleMetalakeBtn);// load metalake- metalake = gravitinoClient.loadMetalake(NameIdentifier.of(METALAKE_NAME));+ metalake = gravitinoClient.loadMetalake(METALAKE_NAME);metalakePage.clickMetalakeLink(METALAKE_NAME);// create doris catalog actionsclickAndWait(catalogsPage.createCatalogBtn);diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.javaindex 407a3bf59d..1d788b835f 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageKafkaTest.java@@ -69,8 +69,7 @@ public class CatalogsPageKafkaTest extends AbstractWebIT {* @param topicName The name of the Kafka topic.*/void createTopic(String metalakeName, String catalogName, String schemaName, String topicName) {- Catalog catalog_kafka =- metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog_kafka = metalake.loadCatalog(catalogName);catalog_kafka.asTopicCatalog().createTopic(@@ -89,8 +88,7 @@ public class CatalogsPageKafkaTest extends AbstractWebIT {* @param topicName The name of the Kafka topic to be dropped.*/void dropTopic(String metalakeName, String catalogName, String schemaName, String topicName) {- Catalog catalog_kafka =- metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog_kafka = metalake.loadCatalog(catalogName);catalog_kafka.asTopicCatalog().dropTopic(NameIdentifier.of(metalakeName, catalogName, schemaName, topicName));@@ -104,7 +102,7 @@ public class CatalogsPageKafkaTest extends AbstractWebIT {metalakePage.setMetalakeNameField(METALAKE_NAME);clickAndWait(metalakePage.submitHandleMetalakeBtn);// load metalake- metalake = gravitinoClient.loadMetalake(NameIdentifier.of(METALAKE_NAME));+ metalake = gravitinoClient.loadMetalake(METALAKE_NAME);metalakePage.clickMetalakeLink(METALAKE_NAME);// create kafka catalog actionsclickAndWait(catalogsPage.createCatalogBtn);diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.javaindex d0e0a4c6ea..5380ebf69b 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.java@@ -212,8 +212,7 @@ public class CatalogsPageTest extends AbstractWebIT {Map<String, String> properties = Maps.newHashMap();properties.put(PROPERTIES_KEY1, PROPERTIES_VALUE1);String storageLocation = storageLocation(schemaName, filesetName);- Catalog catalog_fileset =- metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog_fileset = metalake.loadCatalog(catalogName);catalog_fileset.asFilesetCatalog().createFileset(@@ -245,7 +244,7 @@ public class CatalogsPageTest extends AbstractWebIT {metalakePage.setMetalakeNameField(METALAKE_SELECT_NAME);clickAndWait(metalakePage.submitHandleMetalakeBtn);// load metalake- metalake = gravitinoClient.loadMetalake(NameIdentifier.of(METALAKE_NAME));+ metalake = gravitinoClient.loadMetalake(METALAKE_NAME);metalakePage.clickMetalakeLink(METALAKE_NAME);// create catalogclickAndWait(catalogsPage.createCatalogBtn);@@ -272,7 +271,7 @@ public class CatalogsPageTest extends AbstractWebIT {catalogsPage.setCatalogPropsAt(2, "key2", "value2");clickAndWait(catalogsPage.handleSubmitCatalogBtn);// load catalog- catalog = metalake.loadCatalog(NameIdentifier.of(METALAKE_NAME, HIVE_CATALOG_NAME));+ catalog = metalake.loadCatalog(HIVE_CATALOG_NAME);Assertions.assertTrue(catalogsPage.verifyGetCatalog(HIVE_CATALOG_NAME));}diff --git a/spark-connector/spark-connector/src/main/java/com/datastrato/gravitino/spark/connector/catalog/GravitinoCatalogManager.java b/spark-connector/spark-connector/src/main/java/com/datastrato/gravitino/spark/connector/catalog/GravitinoCatalogManager.javaindex 9884be2d09..5b1d33b8d9 100644--- a/spark-connector/spark-connector/src/main/java/com/datastrato/gravitino/spark/connector/catalog/GravitinoCatalogManager.java+++ b/spark-connector/spark-connector/src/main/java/com/datastrato/gravitino/spark/connector/catalog/GravitinoCatalogManager.java@@ -5,8 +5,6 @@package com.datastrato.gravitino.spark.connector.catalog;import com.datastrato.gravitino.Catalog;-import com.datastrato.gravitino.NameIdentifier;-import com.datastrato.gravitino.Namespace;import com.datastrato.gravitino.client.GravitinoAdminClient;import com.datastrato.gravitino.client.GravitinoMetalake;import com.google.common.base.Preconditions;@@ -34,7 +32,7 @@ public class GravitinoCatalogManager {this.gravitinoClient = GravitinoAdminClient.builder(gravitinoUri).build();// Will not evict catalog by defaultthis.gravitinoCatalogs = CacheBuilder.newBuilder().build();- this.metalake = gravitinoClient.loadMetalake(NameIdentifier.ofMetalake(metalakeName));+ this.metalake = gravitinoClient.loadMetalake(metalakeName);}public static GravitinoCatalogManager create(String gravitinoUrl, String metalakeName) {@@ -73,7 +71,7 @@ public class GravitinoCatalogManager {}public void loadRelationalCatalogs() {- Catalog[] catalogs = metalake.listCatalogsInfo(Namespace.ofCatalog(metalake.name()));+ Catalog[] catalogs = metalake.listCatalogsInfo();Arrays.stream(catalogs).filter(catalog -> Catalog.Type.RELATIONAL.equals(catalog.type())).forEach(catalog -> gravitinoCatalogs.put(catalog.name(), catalog));@@ -84,7 +82,7 @@ public class GravitinoCatalogManager {}private Catalog loadCatalog(String catalogName) {- Catalog catalog = metalake.loadCatalog(NameIdentifier.ofCatalog(metalakeName, catalogName));+ Catalog catalog = metalake.loadCatalog(catalogName);Preconditions.checkArgument(Catalog.Type.RELATIONAL.equals(catalog.type()), "Only support relational catalog");LOG.info("Load catalog {} from Gravitino successfully.", catalogName);diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.javaindex 1ca98dec79..799f87f631 100644--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorManager.java@@ -15,7 +15,6 @@ import static com.datastrato.gravitino.trino.connector.GravitinoErrorCode.GRAVITimport com.datastrato.gravitino.Catalog;import com.datastrato.gravitino.CatalogChange;import com.datastrato.gravitino.NameIdentifier;-import com.datastrato.gravitino.Namespace;import com.datastrato.gravitino.client.GravitinoAdminClient;import com.datastrato.gravitino.client.GravitinoMetalake;import com.datastrato.gravitino.exceptions.CatalogAlreadyExistsException;@@ -125,7 +124,7 @@ public class CatalogConnectorManager {for (String usedMetalake : usedMetalakes) {GravitinoMetalake metalake;try {- metalake = gravitinoClient.loadMetalake(NameIdentifier.ofMetalake(usedMetalake));+ metalake = gravitinoClient.loadMetalake(usedMetalake);LOG.info("Load metalake: {}", usedMetalake);loadCatalogs(metalake);@@ -141,7 +140,7 @@ public class CatalogConnectorManager {public void loadCatalogs(GravitinoMetalake metalake) {NameIdentifier[] catalogNames;try {- catalogNames = metalake.listCatalogs(Namespace.ofCatalog(metalake.name()));+ catalogNames = metalake.listCatalogs();} catch (Exception e) {LOG.error("Failed to list catalogs in metalake {}.", metalake.name(), e);return;@@ -178,7 +177,7 @@ public class CatalogConnectorManager {.forEach((NameIdentifier nameIdentifier) -> {try {- Catalog catalog = metalake.loadCatalog(nameIdentifier);+ Catalog catalog = metalake.loadCatalog(nameIdentifier.name());GravitinoCatalog gravitinoCatalog = new GravitinoCatalog(metalake.name(), catalog);if (catalogConnectors.containsKey(getTrinoCatalogName(gravitinoCatalog))) {// Reload catalogs that have been updated in Gravitino server.@@ -267,20 +266,20 @@ public class CatalogConnectorManager {String provider,Map<String, String> properties,boolean ignoreExist) {- NameIdentifier catalog = NameIdentifier.of(metalakeName, catalogName);if (catalogConnectors.containsKey(getTrinoCatalogName(metalakeName, catalogName))) {if (!ignoreExist) {throw new TrinoException(- GRAVITINO_CATALOG_ALREADY_EXISTS, String.format("Catalog %s already exists.", catalog));+ GRAVITINO_CATALOG_ALREADY_EXISTS,+ String.format(+ "Catalog %s already exists.", NameIdentifier.of(metalakeName, catalogName)));}return;}try {- GravitinoMetalake metalake =- gravitinoClient.loadMetalake(NameIdentifier.ofMetalake(catalog.namespace().toString()));+ GravitinoMetalake metalake = gravitinoClient.loadMetalake(metalakeName);metalake.createCatalog(- catalog, Catalog.Type.RELATIONAL, provider, "Trino created", properties);+ catalogName, Catalog.Type.RELATIONAL, provider, "Trino created", properties);LOG.info("Create catalog {} in metalake {} successfully.", catalogName, metalake);@@ -297,7 +296,9 @@ public class CatalogConnectorManager {} catch (CatalogAlreadyExistsException e) {throw new TrinoException(GRAVITINO_CATALOG_ALREADY_EXISTS,- "Catalog " + catalog + " already exists in the server.");+ "Catalog "+ + NameIdentifier.of(metalakeName, catalogName)+ + " already exists in the server.");} catch (Exception e) {throw new TrinoException(GRAVITINO_UNSUPPORTED_OPERATION, "Create catalog failed. " + e.getMessage(), e);@@ -306,22 +307,22 @@ public class CatalogConnectorManager {public void dropCatalog(String metalakeName, String catalogName, boolean ignoreNotExist) {try {- GravitinoMetalake metalake =- gravitinoClient.loadMetalake(NameIdentifier.ofMetalake(metalakeName));+ GravitinoMetalake metalake = gravitinoClient.loadMetalake(metalakeName);- NameIdentifier catalog = NameIdentifier.of(metalakeName, catalogName);- if (!metalake.catalogExists(catalog)) {+ // NameIdentifier catalog = NameIdentifier.of(metalakeName, catalogName);+ if (!metalake.catalogExists(catalogName)) {if (ignoreNotExist) {return;}throw new TrinoException(- GRAVITINO_CATALOG_NOT_EXISTS, "Catalog " + catalog + " not exists.");+ GRAVITINO_CATALOG_NOT_EXISTS,+ "Catalog " + NameIdentifier.of(metalakeName, catalogName) + " not exists.");}- boolean dropped = metalake.dropCatalog(catalog);+ boolean dropped = metalake.dropCatalog(catalogName);if (!dropped) {throw new TrinoException(- GRAVITINO_UNSUPPORTED_OPERATION, "Drop catalog " + catalog + " does not support.");+ GRAVITINO_UNSUPPORTED_OPERATION, "Drop catalog " + catalogName + " does not support.");}LOG.info("Drop catalog {} in metalake {} successfully.", catalogName, metalake);@@ -380,9 +381,8 @@ public class CatalogConnectorManager {return;}- GravitinoMetalake metalake =- gravitinoClient.loadMetalake(NameIdentifier.ofMetalake(metalakeName));- metalake.alterCatalog(catalog, changes.toArray(changes.toArray(new CatalogChange[0])));+ GravitinoMetalake metalake = gravitinoClient.loadMetalake(metalakeName);+ metalake.alterCatalog(catalogName, changes.toArray(changes.toArray(new CatalogChange[0])));Future<?> future = executorService.submit(this::loadMetalakeImpl);future.get(LOAD_METALAKE_TIMEOUT, TimeUnit.SECONDS);diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.javaindex c431472a44..fd2b7cdf85 100644--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadata.java@@ -55,7 +55,7 @@ public class CatalogConnectorMetadata {try {this.catalogName = catalogIdentifier.name();this.metalake = metalake;- Catalog catalog = metalake.loadCatalog(catalogIdentifier);+ Catalog catalog = metalake.loadCatalog(catalogName);// Make sure the catalog support schema operations.this.schemaCatalog = catalog.asSchemas();this.tableCatalog = catalog.asTableCatalog();diff --git a/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java b/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.javaindex 86fc466389..65821f15a3 100644--- a/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java+++ b/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/GravitinoMockServer.java@@ -65,8 +65,8 @@ public class GravitinoMockServer implements AutoCloseable {private GeneralDataTypeTransformer dataTypeTransformer = new HiveDataTypeTransformer();public GravitinoMockServer() {- createMetalake(NameIdentifier.ofMetalake(testMetalake));- createCatalog(NameIdentifier.ofCatalog(testMetalake, testCatalog));+ createMetalake(testMetalake);+ createCatalog(testMetalake, testCatalog);}public void setCatalogConnectorManager(CatalogConnectorManager catalogConnectorManager) {@@ -76,133 +76,133 @@ public class GravitinoMockServer implements AutoCloseable {public GravitinoAdminClient createGravitinoClient() {GravitinoAdminClient client = mock(GravitinoAdminClient.class);- when(client.createMetalake(any(NameIdentifier.class), anyString(), anyMap()))+ when(client.createMetalake(anyString(), anyString(), anyMap())).thenAnswer(new Answer<GravitinoMetalake>() {@Overridepublic GravitinoMetalake answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier metalakeName = invocation.getArgument(0);+ String metalakeName = invocation.getArgument(0);return createMetalake(metalakeName);}});- when(client.dropMetalake(any(NameIdentifier.class)))+ when(client.dropMetalake(anyString())).thenAnswer(new Answer<Boolean>() {@Overridepublic Boolean answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier metalakeName = invocation.getArgument(0);- metalakes.remove(metalakeName.name());+ String metalakeName = invocation.getArgument(0);+ metalakes.remove(metalakeName);return true;}});- when(client.loadMetalake(any(NameIdentifier.class)))+ when(client.loadMetalake(anyString())).thenAnswer(new Answer<GravitinoMetalake>() {@Overridepublic GravitinoMetalake answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier metalakeName = invocation.getArgument(0);- if (!metalakes.containsKey(metalakeName.name())) {+ String metalakeName = invocation.getArgument(0);+ if (!metalakes.containsKey(metalakeName)) {throw new NoSuchMetalakeException("metalake does not be found");}- return metalakes.get(metalakeName.name()).metalake;+ return metalakes.get(metalakeName).metalake;}});- when(client.metalakeExists(any(NameIdentifier.class)))+ when(client.metalakeExists(anyString())).thenAnswer(new Answer<Boolean>() {@Overridepublic Boolean answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier metalakeName = invocation.getArgument(0);- return metalakes.containsKey(metalakeName.name());+ String metalakeName = invocation.getArgument(0);+ return metalakes.containsKey(metalakeName);}});return client;}- private GravitinoMetalake createMetalake(NameIdentifier metalakeName) {+ private GravitinoMetalake createMetalake(String metalakeName) {GravitinoMetalake metaLake = mock(GravitinoMetalake.class);- when(metaLake.name()).thenReturn(metalakeName.name());- when(metaLake.listCatalogs(any(Namespace.class)))+ when(metaLake.name()).thenReturn(metalakeName);+ when(metaLake.listCatalogs()).thenAnswer(new Answer<NameIdentifier[]>() {@Overridepublic NameIdentifier[] answer(InvocationOnMock invocation) throws Throwable {- return metalakes.get(metalakeName.name()).catalogs.keySet().stream()- .map(catalogName -> NameIdentifier.ofCatalog(metalakeName.name(), catalogName))+ return metalakes.get(metalakeName).catalogs.keySet().stream()+ .map(catalogName -> NameIdentifier.ofCatalog(metalakeName, catalogName)).toArray(NameIdentifier[]::new);};});when(metaLake.createCatalog(- any(NameIdentifier.class), any(Catalog.Type.class), anyString(), anyString(), anyMap()))+ anyString(), any(Catalog.Type.class), anyString(), anyString(), anyMap())).thenAnswer(new Answer<Catalog>() {@Overridepublic Catalog answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier catalogName = invocation.getArgument(0);+ String catalogName = invocation.getArgument(0);- Catalog catalog = createCatalog(catalogName);+ Catalog catalog = createCatalog(metalakeName, catalogName);return catalog;}});- when(metaLake.dropCatalog(any(NameIdentifier.class)))+ when(metaLake.dropCatalog(anyString())).thenAnswer(new Answer<Boolean>() {@Overridepublic Boolean answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier catalogName = invocation.getArgument(0);- if (!metalakes.get(metalakeName.name()).catalogs.containsKey(catalogName.name())) {+ String catalogName = invocation.getArgument(0);+ if (!metalakes.get(metalakeName).catalogs.containsKey(catalogName)) {throw new NoSuchCatalogException("catalog does not be found");}- metalakes.get(metalakeName.name()).catalogs.remove(catalogName.name());+ metalakes.get(metalakeName).catalogs.remove(catalogName);return true;}});- when(metaLake.catalogExists(any(NameIdentifier.class)))+ when(metaLake.catalogExists(anyString())).thenAnswer(new Answer<Boolean>() {@Overridepublic Boolean answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier catalogName = invocation.getArgument(0);- return metalakes.get(metalakeName.name()).catalogs.containsKey(catalogName.name());+ String catalogName = invocation.getArgument(0);+ return metalakes.get(metalakeName).catalogs.containsKey(catalogName);}});- when(metaLake.loadCatalog(any(NameIdentifier.class)))+ when(metaLake.loadCatalog(anyString())).thenAnswer(new Answer<Catalog>() {@Overridepublic Catalog answer(InvocationOnMock invocation) throws Throwable {- NameIdentifier catalogName = invocation.getArgument(0);- if (!metalakes.get(metalakeName.name()).catalogs.containsKey(catalogName.name())) {+ String catalogName = invocation.getArgument(0);+ if (!metalakes.get(metalakeName).catalogs.containsKey(catalogName)) {throw new NoSuchCatalogException("catalog does not be found");}- return metalakes.get(metalakeName.name()).catalogs.get(catalogName.name());+ return metalakes.get(metalakeName).catalogs.get(catalogName);}});- metalakes.put(metalakeName.name(), new Metalake(metaLake));+ metalakes.put(metalakeName, new Metalake(metaLake));return metaLake;}void reloadCatalogs() {GravitinoMetalake metaLake = mock(GravitinoMetalake.class);when(metaLake.name()).thenReturn(testMetalake);- when(metaLake.listCatalogs(any()))+ when(metaLake.listCatalogs()).thenReturn(new NameIdentifier[] {NameIdentifier.ofCatalog(testMetalake, testCatalog)});catalogConnectorManager.loadCatalogs(metaLake);}- private Catalog createCatalog(NameIdentifier catalogName) {+ private Catalog createCatalog(String metalakeName, String catalogName) {Catalog catalog = mock(Catalog.class);- when(catalog.name()).thenReturn(catalogName.name());+ when(catalog.name()).thenReturn(catalogName);when(catalog.provider()).thenReturn(testCatalogProvider);when(catalog.type()).thenReturn(Catalog.Type.RELATIONAL);when(catalog.properties()).thenReturn(Map.of("max_ttl", "10"));@@ -216,7 +216,7 @@ public class GravitinoMockServer implements AutoCloseable {when(catalog.asTableCatalog()).thenAnswer(answer -> createTableCatalog(gravitinoCatalog));when(catalog.asSchemas()).thenAnswer(answer -> createSchemas(gravitinoCatalog));- metalakes.get(catalogName.namespace().toString()).catalogs.put(catalogName.name(), catalog);+ metalakes.get(metalakeName).catalogs.put(catalogName, catalog);return catalog;}diff --git a/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/TestGravitinoConnectorWithMetalakeCatalogName.java b/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/TestGravitinoConnectorWithMetalakeCatalogName.javaindex bff123d1bc..757a970722 100644--- a/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/TestGravitinoConnectorWithMetalakeCatalogName.java+++ b/trino-connector/src/test/java/com/datastrato/gravitino/trino/connector/TestGravitinoConnectorWithMetalakeCatalogName.java@@ -10,7 +10,6 @@ import static org.assertj.core.api.Assertions.assertThat;import static org.testng.Assert.assertEquals;import static org.testng.Assert.assertFalse;-import com.datastrato.gravitino.NameIdentifier;import com.datastrato.gravitino.client.GravitinoAdminClient;import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorManager;import io.trino.Session;@@ -111,7 +110,7 @@ public class TestGravitinoConnectorWithMetalakeCatalogName extends AbstractTestQ// test metalake named test1. the connnector name is test1GravitinoAdminClient gravitinoClient = server.createGravitinoClient();- gravitinoClient.createMetalake(NameIdentifier.ofMetalake("test1"), "", Collections.emptyMap());+ gravitinoClient.createMetalake("test1", "", Collections.emptyMap());assertUpdate("call test1.system.create_catalog('memory1', 'memory', Map())");assertThat(computeActual("show catalogs").getOnlyColumnAsSet()).contains("test1.memory1");