diff --git a/docs/content/program-api/catalog-api.md b/docs/content/program-api/catalog-api.md index 6dbe8d766878..7e716aad15bb 100644 --- a/docs/content/program-api/catalog-api.md +++ b/docs/content/program-api/catalog-api.md @@ -82,7 +82,7 @@ public class ListDatabases { ## Drop Database -You can use the catalog to drop databases. +You can use the catalog to drop database. ```java import org.apache.paimon.catalog.Catalog; @@ -104,7 +104,7 @@ public class DropDatabase { ## Alter Database -You can use the catalog to alter databases.(ps: only support hive and jdbc catalog) +You can use the catalog to alter database's properties.(ps: only support hive and jdbc catalog) ```java import java.util.ArrayList; diff --git a/paimon-core/src/test/java/org/apache/paimon/catalog/CatalogTestBase.java b/paimon-core/src/test/java/org/apache/paimon/catalog/CatalogTestBase.java index 029fbb82b6f4..986b4b83c7cb 100644 --- a/paimon-core/src/test/java/org/apache/paimon/catalog/CatalogTestBase.java +++ b/paimon-core/src/test/java/org/apache/paimon/catalog/CatalogTestBase.java @@ -964,28 +964,47 @@ public void testTableUUID() throws Exception { protected void alterDatabaseWhenSupportAlter() throws Exception { // Alter database - String databaseName = "db_to_alter_alert"; + String databaseName = "db_to_alter"; catalog.createDatabase(databaseName, false); - String key = "key"; + String key = "key1"; + String key2 = "key2"; // Add property catalog.alterDatabase( - databaseName, Lists.newArrayList(DatabaseChange.setProperty(key, "value")), false); + databaseName, + Lists.newArrayList( + DatabaseChange.setProperty(key, "value"), + DatabaseChange.setProperty(key2, "value")), + false); Database db = catalog.getDatabase(databaseName); assertEquals("value", db.options().get(key)); + assertEquals("value", db.options().get(key2)); // Update property catalog.alterDatabase( - databaseName, Lists.newArrayList(DatabaseChange.setProperty(key, "value1")), false); + databaseName, + Lists.newArrayList( + DatabaseChange.setProperty(key, "value1"), + DatabaseChange.setProperty(key2, "value1")), + false); db = catalog.getDatabase(databaseName); assertEquals("value1", db.options().get(key)); + assertEquals("value1", db.options().get(key2)); // remove property catalog.alterDatabase( - databaseName, Lists.newArrayList(DatabaseChange.removeProperty(key)), false); + databaseName, + Lists.newArrayList( + DatabaseChange.removeProperty(key), DatabaseChange.removeProperty(key2)), + false); db = catalog.getDatabase(databaseName); assertEquals(false, db.options().containsKey(key)); + assertEquals(false, db.options().containsKey(key2)); // Remove non-existent property catalog.alterDatabase( - databaseName, Lists.newArrayList(DatabaseChange.removeProperty(key)), false); + databaseName, + Lists.newArrayList( + DatabaseChange.removeProperty(key), DatabaseChange.removeProperty(key2)), + false); db = catalog.getDatabase(databaseName); assertEquals(false, db.options().containsKey(key)); + assertEquals(false, db.options().containsKey(key2)); } }